名字空单错误:
<%@ Import Namespace="System.Data" %> 
<%@ Import Namespace="System.Data.SQLClient" %> 

解决方案 »

  1.   

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatasqlclient.asp
      

  2.   

    改成<%@ Import Namespace="System.Data.SQLClient" %> ,错误依旧!
      

  3.   

    要改成<%@ Import Namespace="System.Data.SqlClient" %>不过错误又来了
    行 7:  
    行 8:  <script language="C#" runat="server"> 
    行 9:  public SQLDataReader myReader; 
    行 10: public String html; 
    行 11: 源文件: c:\prctj\test.aspx    行: 9 
      

  4.   

    编译错误 
    说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。 编译器错误信息: CS0117: “System.Data.SqlClient.SqlCommand”并不包含对“Execute”的定义源错误: 行 11:  try {
    行 12:  mySqlConnection.Open();
    行 13:  mySqlCommand.Execute(out myReader);
    行 14:  html="<Table>";
    行 15:  html+="<TR>";
     源文件: c:\prctj\test.aspx    行: 13 
    <%@ Import Namespace="System.Data" %> 
    <%@ Import Namespace="System.Data.SqlClient" %> 
    <html> 
    <head>
    <script language="C#" runat="server">
    public SqlDataReader myReader;
    public String html;
    protected void Page_Load(Object Src, EventArgs E) {
    SqlConnection mySqlConnection = new SqlConnection("server=localhost;uid=sa;pwd=;database=northwind");
    SqlCommand mySqlCommand = new SqlCommand("select * from customers", mySqlConnection);
    try {
    mySqlConnection.Open();
    mySqlCommand.Execute(out myReader);
    html="<Table>";
    html+="<TR>";
    html+="<TD><B>Customer ID</B></TD>";
    html+="<TD><B>Company Name</B></TD>";
    html+="</TR>";
    while (myReader.Read()) {
    html+="<TR>";
    html+="<TD>" + myReader["CustomerID"].ToString() + "</TD>";
    html+="<TD>" + myReader["CompanyName"].ToString() + "</TD>";
    html+="</TR>";
    }
    html+="</Table>";
    }
    catch(Exception e) {
    html=e.ToString();
    }
    finally{
    myReader.Close();
    mySqlConnection.Close();
    }
    Response.Write(html);
    }
    </script>
    </head>
    <body>
    </body>
    </html>
      

  5.   

    mySqlCommand.Execute(out myReader);
    ----------》SqlDataReader myReader = mySqlCommand.ExecuteReader();
      

  6.   

    你看的教程太老太老了
    从这里看去
    http://chs.gotdotnet.com/quickstart/
      

  7.   

    居然被我用VB改对了,晕倒!!!<%@ Import Namespace="System.Data" %> 
    <%@ Import Namespace="System.Data.SqlClient" %> 
    <html> 
    <head>
    <script language="VB" runat="server">
    Dim myReader As SqlDataReader
    Dim html As String
    Sub Page_Load(Sender As Object,e As EventArgs)
    Dim mySqlConnection As SqlConnection = new SqlConnection("server=localhost;uid=sa;pwd=sa;database=northwind")
    Dim mySqlCommand As SqlCommand = new SqlCommand("select * from customers", mySqlConnection)
    mySqlConnection.Open()
    myReader=mySqlCommand.ExecuteReader()
    html="<Table>"
    html+="<TR>"
    html+="<TD><B>Customer ID</B></TD>"
    html+="<TD><B>Company Name</B></TD>"
    html+="</TR>"
    Do while myReader.Read()
    html+="<TR>"
    html+="<TD>" + myReader("CustomerID").ToString() + "</TD>"
    html+="<TD>" + myReader("CompanyName").ToString() + "</TD>"
    html+="</TR>"
    loop
    html+="</Table>"
    Response.Write(html)
    End Sub
    </script>
    </head>
    <body>
    </body>
    </html>
      

  8.   

    TO: xiahouwen(活靶子.NET)  
     
      mySqlCommand.Execute(out myReader);改成
     SqlDataReader myReader = mySqlCommand.ExecuteReader();后出以下错误
      
     未将对象引用设置到对象的实例。 
    说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。源错误: 生成此未处理异常的源代码只能在调试模式中进行编译时显示。若要启用该功能,请执行以下步骤之一,然后请求 URL:1. 在生成错误的文件的顶部添加一个“Debug=true”指令。示例:  <%@ Page Language="C#" Debug="true" %>或者:2. 将以下节添加到应用程序的配置文件中:<configuration>
       <system.web>
           <compilation debug="true"/>
       </system.web>
    </configuration>请注意,第二种方法将使给定应用程序中的所有文件在调试模式下进行编译。第一种方法只使特定文件在调试模式下进行编译。重要事项:以调试模式运行应用程序肯定会引起内存/性能系统开销。在部署到产品方案中之前,应该确保应用程序已禁用调试。  堆栈跟踪: 
    [NullReferenceException: 未将对象引用设置到对象的实例。]
       ASP.test2_aspx.Page_Load(Object Src, EventArgs E) +530
       System.Web.UI.Control.OnLoad(EventArgs e) +67
       System.Web.UI.Control.LoadRecursive() +29
       System.Web.UI.Page.ProcessRequestMain() +724 
      

  9.   

    new一下试试
    Dim myReader As  SqlDataReader= new SqlDataReader()
      

  10.   

    VB这个已经运行通过了,我说的是C#那个
      

  11.   

    错误好像出在try {...} catch 上
      

  12.   

    finally{
    //myReader.Close();
    //mySqlConnection.Close();
    }这样就好了,问题出在这里!