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
.NET ProgrammingVisual Basic.NET

Avatar of undefined
Last Comment
kerryw60
Avatar of kerryw60
kerryw60

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

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
.NET Programming
.NET Programming

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

137K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo