I'm trying my hand at ASP.NET for the first time, but I'm having issues connecting to my database. When I type these import statements: <% @Language="c#" AutoEventWireup="false" CodeBehind="Default.aspx.vb"%> <%@ import namespace="system" %> <%@ import namespace="system.data" %> <%@ import namespace="system.data.sqlclient" %> I get the error "CS0246: The type or namespace name 'system' could not be found" at line 4 (the last line). More specifically, I'm trying to implement the code below from the knowledge base, but I can't get past this import statement error.Also, if I delete lines 2 and 3 from my code I still get the error. <%@ import namespace="system.data.sqlclient" %> <Script runat="server"> Sub page_load Dim dbconn as sqlconnection Dim dbCMD as sqlCommand Dim dtr as sqldatareader dbConn = New SQLConnection ("Data Source=DBSERVERNAME;Initial Catalog=YOURDBNAME;User ID=YOURUSERID;Password=YOURPASSWORD") dbConn.open() dbCMD = new sqlcommand ("select * from tblTest",dbconn) dtr = dbCMD.executereader() While dtr.read() response.write ("<li>") response.write (dtr(0) & "---" & dtr(1)) End while dtr.close() dbConn.close() End Sub </Script>
Try adding in this using statement "using System.Data.Sql;" I usually add my db info in *.aspx.cs file