book lending systemLoss function and Borrow table as shown in figure,
Realize when input Borrow existing codes and library card number bor_number b_number, modify the loss in the Borrow,
The current code can perform but didn't work for the table, but with SQLSTR="update Borrow set loss='" & amp; Trim (TextBox3. Text) & amp; "' the where bor_time='" & amp; Trim (DateTimePicker1. Value) & amp; "' and bac_time=" & amp; Trim (DateTimePicker2. Value) & amp; "'" can perform, I found that as long as is the primary key of another table cannot be achieved, but get rid of the primary key can't achieve function, help!!!
Code: Dim conn As SqlConnection
Private Sub Button1_Click (sender As Object, As EventArgs e) Handles for. Click
Try
Me. The Validate ()
Me. BorrBindingSource1. EndEdit ()
Me. BorrowTableAdapter. Update Me. YSDataSet1. (Borrow)
Conn=New SqlConnection ()
Conn. The ConnectionString="Data Source=DESKTOP - 0 VDRKDC; Initial Catalog=student1; Integrated Security=True "
Conn. The Open ()
Dim SQLSTR As String
SQLSTR="update Borrow set loss='" & amp; Trim (TextBox3. Text) & amp; "' the where bor_number='" & amp; Trim (TextBox1. Text) & amp; "' and b_number=" & amp; Trim (TextBox2. Text) & amp; "' and bor_time=" & amp; Trim (DateTimePicker1. Value) & amp; "' and bac_time=" & amp; Trim (DateTimePicker2. Value) & amp; "'
"Dim comm As New SqlCommand (SQLSTR, conn.)
Comm. ExecuteNonQuery ()
Conn. Close ()
MsgBox (" add information ")
Catch the ex As Exception
MessageBox. Show (ex. Message)
End the Try
End Sub
CodePudding user response:
SQL statements like 2 list processing example,CodePudding user response:
Print SQLSTR then put in the database to perform, see if there are any success, had better have a look at your data, you type of char (10), the data is not full 10, automatically added Spaces, but when you check the condition of no space, must be matchedCodePudding user response:
Char (10) to varchar (10) or nvarchar (10), obviously you don't know the data type, cha