Hi, i have SQL Server 200 desktop engine installed on my machine. and i tried to connect to the Northwind database that comes with sql server 2000 using
VB.Net. I am getting following error.
c:\inetpub\wwwroot\SQLserver_conn\WebForm1.aspx.
vb (26):
Declaration expected.
Declaration expected
Type 'SqlConnection' is not defined.
Type 'SqlCommand' is not defined.
so i think i am having problem with Import System.Data and Import System.Data.SqlClient
My code is as follow:
Import System.Data
Import System.Data.SqlClient
Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents dgNameList As System.Web.UI.WebControls.DataGrid
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim strConnection As String = "server=(local)\NARESH-SIR; database=Northwind; integrated security = true;"
Dim objConnection As New SqlConnection(strConnection)
Dim strSQL As String = "Select FirstName, LastName, Country from Employees"
Dim objCommand As New SqlCommand(strSQL, objConnection)
objConnection.open()
dgNameList.DataSource = objCommand.ExecuteReader()
dgNameList.DataBind()
objConnection.close()
End Sub
Can anyone help me please.