Hi,
I need need help on my program.
I am suppose to do a VB form where it can be able to read, add, update and delete citectSCADA variables from access .
But after entering the following code into my add button. my form jus hang.
i tried F11. But still it didnt tell me the problem about it.
Private Sub BtnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnAdd.Click
Dim N As String
Dim T As String
Dim U As String
Dim A As String
N = NAMETextBox.Text
T = TYPEComboBox.SelectedItem
U = UNITComboBox.SelectedItem
A = ADDRTextBox.Text
Dim SQLStr As String
Dim ConnString As String = "Data Source=|DataDirectory|\variable.mdb"
SQLStr = "INSERT into variable (NAME,TYPE,UNIT,ADDR) VALUES (@name,@type,@unit,@addr)"
Dim SQLConn As New SqlConnection()
Dim SQLCmd As New SqlCommand()
SQLConn.ConnectionString = ConnString
SQLConn.Open()
SQLCmd.Connection = SQLConn
SQLCmd.CommandText = SQLStr
SQLCmd.Parameters.AddWithValue("@name", N)
SQLCmd.Parameters.AddWithValue("@type", T)
SQLCmd.Parameters.AddWithValue("@unit", U)
SQLCmd.Parameters.AddWithValue("@addr", A)
Try
SQLCmd.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
SQLConn.Close()
End Try
'Me.VariableDataSet.Clear()
'Me.VariableTableAdapter.Fill(Me.VariableDataSet.variable)
End Sub
I need need help on my program.
I am suppose to do a VB form where it can be able to read, add, update and delete citectSCADA variables from access .
But after entering the following code into my add button. my form jus hang.
i tried F11. But still it didnt tell me the problem about it.
Private Sub BtnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnAdd.Click
Dim N As String
Dim T As String
Dim U As String
Dim A As String
N = NAMETextBox.Text
T = TYPEComboBox.SelectedItem
U = UNITComboBox.SelectedItem
A = ADDRTextBox.Text
Dim SQLStr As String
Dim ConnString As String = "Data Source=|DataDirectory|\variable.mdb"
SQLStr = "INSERT into variable (NAME,TYPE,UNIT,ADDR) VALUES (@name,@type,@unit,@addr)"
Dim SQLConn As New SqlConnection()
Dim SQLCmd As New SqlCommand()
SQLConn.ConnectionString = ConnString
SQLConn.Open()
SQLCmd.Connection = SQLConn
SQLCmd.CommandText = SQLStr
SQLCmd.Parameters.AddWithValue("@name", N)
SQLCmd.Parameters.AddWithValue("@type", T)
SQLCmd.Parameters.AddWithValue("@unit", U)
SQLCmd.Parameters.AddWithValue("@addr", A)
Try
SQLCmd.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
SQLConn.Close()
End Try
'Me.VariableDataSet.Clear()
'Me.VariableTableAdapter.Fill(Me.VariableDataSet.variable)
End Sub