Hi,
Working with a purchased application and just started working with VB.net. Can somebody help me with how to write code behind a command button to run a SQL script that would insert data in a table.
Here is the code I have -
Imports System.Windows.Forms
Imports System.Data
Imports System.Data.Common
Imports System.Data.SqlClient.SqlCommand
Imports System.Data.SqlClient.SqlConnection
Namespace Bryanlgh.Cath
Public Class Lesions
Inherits System.Windows.Forms.UserControl
Private Sub LxButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LxButton1.Click
Dim i As Integer = 0
Dim sql As String = "INSERT INTO Items(Item_Name,Vendor_Name)" & _
' " VALUES ( 'Insert' , 'Test' )"
Dim SqlConnection As Data.SqlClient.SqlConnection
Using cn As New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("Apollo_test").ConnectionString)
End Using
End Sub
End Class
This is the error message that I get -
'Error 1 Type 'SqlConnection' is not defined. C:\Program Files\Lumedx\CardioDoc Toolkit\UDF\Source\BryanLGH\Cath\Lesions.vb 555 25 CardioDocProject'
How should I define SQlConnection. I already have the Imports System.Data.SqlClient.SqlConnection. I also have the Dim SqlConnection As Data.SqlClient.SqlConnection. The database I am working with is Apollo_Test and the server name is cpacssql. Any help will be greatly appreciated.
Thanks.
Working with a purchased application and just started working with VB.net. Can somebody help me with how to write code behind a command button to run a SQL script that would insert data in a table.
Here is the code I have -
Imports System.Windows.Forms
Imports System.Data
Imports System.Data.Common
Imports System.Data.SqlClient.SqlCommand
Imports System.Data.SqlClient.SqlConnection
Namespace Bryanlgh.Cath
Public Class Lesions
Inherits System.Windows.Forms.UserControl
Private Sub LxButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LxButton1.Click
Dim i As Integer = 0
Dim sql As String = "INSERT INTO Items(Item_Name,Vendor_Name)" & _
' " VALUES ( 'Insert' , 'Test' )"
Dim SqlConnection As Data.SqlClient.SqlConnection
Using cn As New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("Apollo_test").ConnectionString)
End Using
End Sub
End Class
This is the error message that I get -
'Error 1 Type 'SqlConnection' is not defined. C:\Program Files\Lumedx\CardioDoc Toolkit\UDF\Source\BryanLGH\Cath\Lesions.vb 555 25 CardioDocProject'
How should I define SQlConnection. I already have the Imports System.Data.SqlClient.SqlConnection. I also have the Dim SqlConnection As Data.SqlClient.SqlConnection. The database I am working with is Apollo_Test and the server name is cpacssql. Any help will be greatly appreciated.
Thanks.
Last edited: