J
Jeff Thur
I seem to have a problem with Web Matrix.
When attempting to write the line:
Imports System.Data.SQLClient at the top of my code, this
doesnot seem to be taking. How do I know?
When attempted to run a Microsoft example of executing an
example from ASP.Net I am getting pounded with errors on
code that is correct. This is the Microsoft example code.
Dim sConnectionString As String = _
"server=localhost;uid=sa;pwd=;database=Northwind"
Dim cnNorthwind As New SqlConnection(sConnectionString)
Dim cmdOrders As New SqlCommand("CustOrderHist",
cnNorthwind)
cmdOrders.CommandType = CommandType.StoredProcedure
' Set up parameter for stored procedure
Dim prmCustomerID As New SqlParameter()
prmCustomerID.ParameterName = "@CustomerID"
prmCustomerID.SqlDbType = SqlDbType.VarChar
prmCustomerID.Size = 5
prmCustomerID.Value = "ALFKI"
cmdOrders.Parameters.Add(prmCustomerID
These are my errors:
C:\BegASPNET11\Ch04\mark.aspx(6) : error BC30002:
Type 'SqlConnection' is not defined.
Dim cnNorthwind As New SqlConnection
(sConnectionString)
~~~~~~~~~~~~~
C:\BegASPNET11\Ch04\mark.aspx(7) : error BC30002:
Type 'SqlCommand' is not defined.
Dim cmdOrders As New SqlCommand("CustOrderHist",
cnNorthwind)
~~~~~~~~~~
C:\BegASPNET11\Ch04\mark.aspx(8) : error BC30188:
Declaration expected.
cmdOrders.CommandType = CommandType.StoredProcedure
~~~~~~~~~
C:\BegASPNET11\Ch04\mark.aspx(10) : error BC30188:
Declaration expected.
cmdOrders.Parameters.Add(New _
~~~~~~~~~
C:\BegASPNET11\Ch04\mark.aspx(12) : error BC30188:
Declaration expected.
cmdOrders.Parameters("@CustomerID").Value = "ALFKI"
~~~~~~~~~
C:\BegASPNET11\Ch04\mark.aspx(14) : error BC30002:
Type 'SqlDataAdapter' is not defined.
Dim daGetOrders As New SqlDataAdapter(cmdOrders)
~~~~~~~~~~~~~~
C:\BegASPNET11\Ch04\mark.aspx(15) : error BC30002:
Type 'DataSet' is not defined.
Dim dsOrders As New DataSet()
~~~~~~~
C:\BegASPNET11\Ch04\mark.aspx(16) : error BC30188:
Declaration expected.
daGetOrders.Fill(dsOrders, "Orders")
~~~~~~~~~~~
C:\BegASPNET11\Ch04\mark.aspx(17) : error BC30188:
Declaration expected.
DataGrid1.DataSource = dsOrders.Tables("Orders")
~~~~~~~~~
When attempting to write the line:
Imports System.Data.SQLClient at the top of my code, this
doesnot seem to be taking. How do I know?
When attempted to run a Microsoft example of executing an
example from ASP.Net I am getting pounded with errors on
code that is correct. This is the Microsoft example code.
Dim sConnectionString As String = _
"server=localhost;uid=sa;pwd=;database=Northwind"
Dim cnNorthwind As New SqlConnection(sConnectionString)
Dim cmdOrders As New SqlCommand("CustOrderHist",
cnNorthwind)
cmdOrders.CommandType = CommandType.StoredProcedure
' Set up parameter for stored procedure
Dim prmCustomerID As New SqlParameter()
prmCustomerID.ParameterName = "@CustomerID"
prmCustomerID.SqlDbType = SqlDbType.VarChar
prmCustomerID.Size = 5
prmCustomerID.Value = "ALFKI"
cmdOrders.Parameters.Add(prmCustomerID
These are my errors:
C:\BegASPNET11\Ch04\mark.aspx(6) : error BC30002:
Type 'SqlConnection' is not defined.
Dim cnNorthwind As New SqlConnection
(sConnectionString)
~~~~~~~~~~~~~
C:\BegASPNET11\Ch04\mark.aspx(7) : error BC30002:
Type 'SqlCommand' is not defined.
Dim cmdOrders As New SqlCommand("CustOrderHist",
cnNorthwind)
~~~~~~~~~~
C:\BegASPNET11\Ch04\mark.aspx(8) : error BC30188:
Declaration expected.
cmdOrders.CommandType = CommandType.StoredProcedure
~~~~~~~~~
C:\BegASPNET11\Ch04\mark.aspx(10) : error BC30188:
Declaration expected.
cmdOrders.Parameters.Add(New _
~~~~~~~~~
C:\BegASPNET11\Ch04\mark.aspx(12) : error BC30188:
Declaration expected.
cmdOrders.Parameters("@CustomerID").Value = "ALFKI"
~~~~~~~~~
C:\BegASPNET11\Ch04\mark.aspx(14) : error BC30002:
Type 'SqlDataAdapter' is not defined.
Dim daGetOrders As New SqlDataAdapter(cmdOrders)
~~~~~~~~~~~~~~
C:\BegASPNET11\Ch04\mark.aspx(15) : error BC30002:
Type 'DataSet' is not defined.
Dim dsOrders As New DataSet()
~~~~~~~
C:\BegASPNET11\Ch04\mark.aspx(16) : error BC30188:
Declaration expected.
daGetOrders.Fill(dsOrders, "Orders")
~~~~~~~~~~~
C:\BegASPNET11\Ch04\mark.aspx(17) : error BC30188:
Declaration expected.
DataGrid1.DataSource = dsOrders.Tables("Orders")
~~~~~~~~~