ODBC + Textbox + Delete Record 使用方法
Form1.vb |
Private Sub ODBCDeleteData() 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 = "DELETE FROM dbo.Team 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 |