ODBC + Textbox + Update Record 使用方法
Form1.vb |
Private Sub ODBCUpdateData() Dim ConnString As String = _ "Driver={SQL Native Client};" & _ "Server=VECTUS\SQLEXPRESS;" & _ "Database=Soccer;Trusted_Connection=yes;" Dim ODBCConnection1 As New Odbc.OdbcConnection(ConnString) Try ODBCConnection1.Open() Dim SqlString1 As String = "UPDATE dbo.Team SET Team_Name='" & TextBox5.Text.ToString.Trim & _ "', League_ID='" & TextBox6.Text.ToString.Trim & _ "' WHERE Team_ID = '" & TextBox4.Text.ToString.Trim & "'" Dim cmd1 As OdbcCommand = New OdbcCommand(SqlString1, ODBCConnection1) cmd1.ExecuteNonQuery() cmd1.Dispose() ODBCConnection1.Dispose() Catch ex As Exception MsgBox("Cannot open connection ! ") End Try End Sub |