代码如下:已经更新成功了,但是却没有提示。第一个msgbox在为空时候可以提示的。就是在TRY里面的不会提示。 换成MESSAGEBOX.SHOW也不行。
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If TextBox8.Text = "" Or TextBox9.Text = "" Or MaskedTextBox1.Text = "" Then
MsgBox("Please input above")
End If
Dim mycn As New SqlClient.SqlConnection
Dim mycom As New SqlClient.SqlCommand
mycn.ConnectionString = "Data Source=192.168.0.215;Initial Catalog=blue;uid=sa;pwd=Wks123"
mycom.CommandText = " Update KnitC set Cleaner ='" & MaskedTextBox1.Text & "' where substring(filenm,1,4)='" & TextBox8.Text & "' and substring(filenm,charindex('.',FileNM)+1,LEN(fileNM)-charindex('.',fileNM))='" & TextBox9.Text & "'"
mycom.Connection = mycn
Try
mycn.Open()
Dim mysqlreader As Data.SqlClient.SqlDataReader = mycom.ExecuteReader
If mycom.ExecuteNonQuery > 0 Then
MsgBox("Save success")
Else
MsgBox("Save Fail")
End If
Catch ex As Exception
Finally
mycn.Close()
End Try
End Sub