Dim cnnstr As String
cnnstr = "Provider=SQLOLEDB;" & _
"Data Source=ABC\SQLEXPRESS;" & _
"Initial Catalog= XYZ;" & _
"Integrated Security=SSPI;" & _
"uid=;pwd=;"
Dim myConnection As OleDbConnection = New OleDbConnection(cnnstr)
myConnection.Open()
Dim SQLStr As String
SQLStr = "delete from Customers where CNAME= '" & CustomerNameTextBox.Text & "' , CPHONE='" & MobileTextBox.Text & "' , CTABLE='" & TableTextBox.Text & "' , CDATE='" & DateTextBox.Text & "' , CTIME= '" & TimeTextBox.Text & "'"
Dim myCmd As New OleDbCommand
myCmd.Connection = myConnection
myCmd.CommandText = SQLStr
myCmd.CommandType = CommandType.Text
Try
myCmd.ExecuteNonQuery()
MessageBox.Show("Customer account deleted")
Catch ex As Exception
MessageBox.Show("err msg")
myConnection.Close()
End Try
End Sub
Tags: