Help with the ASP Web Matrix

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")
~~~~~~~~~
 
C

Cor Ligthert

Jeff,

When you place messages in this newsgroup don't tell that you use Web
Matrix.
Most of people active in this newsgoup use Visual Studio Net what is another
approach of dotNet.

A good newsgroup for your needs is in my opinion.
Aspnet
news://msnews.microsoft.com/microsoft.public.dotnet.framework.aspnet

Web interface:
http://communities2.microsoft.com/c.../?dg=microsoft.public.dotnet.framework.aspnet

A good base of information
http://samples.gotdotnet.com/quickstart/

The samples on MSDE are partially based on the scripting style you use and
partially on the Visual.Studio Net style. What is in my opinion very
confusing when you don't know that.

You miss probably at least in your program the import of the namespaces in
top of your program
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>

I hope this helps?

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top