fsuedu
asked on
Visual Studio Visual Basic Code Error
Hello,
Getting error
Error 2 Type 'SqlCommand' is not defined
from previous help on statment
Private Sub Testbutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Testbutton.Click
Dim colCmd As New SqlCommand
Dim objConn As New SqlConnection("")
Dim locTab As New DataTable
Try
objConn.Open()
With colCmd
.CommandType = CommandType.Text
.CommandText = "INSERT INTO Settlement VALUES(" & PreviouAdvDepositstxtTextB ox.Text & ", " & TransferGuestLedgertxt.Tex t & "," & Activityadvdeposittxt.Text & "," & transferfromadvdeposittxt. Text & ", " & transfromguesttoadvtxt.Tex t & "," & Advchangefrominctxt.Text & ")"
.Connection = objConn
.ExecuteNonQuery()
End With
objConn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message )
End Try
End Sub
Where should I put the Imports System.Data.SqlClient statment?
Thanks JK
Getting error
Error 2 Type 'SqlCommand' is not defined
from previous help on statment
Private Sub Testbutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Testbutton.Click
Dim colCmd As New SqlCommand
Dim objConn As New SqlConnection("")
Dim locTab As New DataTable
Try
objConn.Open()
With colCmd
.CommandType = CommandType.Text
.CommandText = "INSERT INTO Settlement VALUES(" & PreviouAdvDepositstxtTextB
.Connection = objConn
.ExecuteNonQuery()
End With
objConn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message
End Try
End Sub
Where should I put the Imports System.Data.SqlClient statment?
Thanks JK
Outside the form class, just put at very top.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.