Link to home
Start Free TrialLog in
Avatar of fsuedu
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(" & PreviouAdvDepositstxtTextBox.Text & ", " & TransferGuestLedgertxt.Text & "," & Activityadvdeposittxt.Text & "," & transferfromadvdeposittxt.Text & ", " & transfromguesttoadvtxt.Text & "," & 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
Avatar of kerryw60
kerryw60

Outside the form class, just put at very top.
ASKER CERTIFIED SOLUTION
Avatar of kerryw60
kerryw60

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial