System.Data.OleDb为System.Data.SqlClient
其他OleDb改为Sql
连接串也改一下

解决方案 »

  1.   

    using System.Data.SqlClient;
    private void Page_Load(object sender, System.EventArgs e) 
    {
    string myConn="server=localhost;database=northwind;uid=sa;pwd=sa;";
    string mySelectQuery ="SELECT * FROM mima where 学号='"+Request.QueryString["xuehao"]+"'";
    this.myConnection = new System.Data.SqlClient.SqlConnection(myConn);
    this.myCommand = new System.Data.SqlClient.SqlCommand(mySelectQuery,myConnection);
    this.myConnection.Open();
    System.Data.SqlClient.SqlDataReader( );
    this.myReader= myCommand.ExecuteReader();
    Always call Read before accessing data.
    while (myReader.Read()) {
                    this.xuehao.Text=myReader["学号"].ToString();
                    this.xingming.Text=myReader["姓名"].ToString();
                    this.mima.Text=myReader["密码"].ToString();
                    this.tswt.Text=myReader["提示问题"].ToString();
                    this.hdwt.Text=myReader["回答问题"].ToString();
    }
    // always call Close when done reading.
           this.myReader.Close();
    // Close the connection when done with it.
           this.myConnection.Close();
    }
      

  2.   

    差不多啊
    就是把连接字符串稍微改一下
    workstation id="";packet size=4096;user id=;data source="";persist security info=True;initial catalog=;password=
      

  3.   

    我改了,可是不行啊...
    F:\WEB\student\cgdl.aspx.cs(42): 无法将类型“System.Data.SqlClient.SqlConnection”隐式转换为“System.Data.OleDb.OleDbConnection”
    F:\WEB\student\cgdl.aspx.cs(43): 与System.Data.SqlClient.SqlCommand.SqlCommand(string, System.Data.SqlClient.SqlConnection)”最匹配的重载方法具有一些无效参数
    F:\WEB\student\cgdl.aspx.cs(43): 参数“2” : 无法从“System.Data.OleDb.OleDbConnection”转换为“System.Data.SqlClient.SqlConnection”......我是按boarduck(davieou)说的方法改的啊!!!
      

  4.   

    引用是这样的:
    using System;
    using System.Data.SqlClient;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.SessionState;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;namespace ltq
    {
    /// <summary>
    /// mydb的摘要说明。
    /// </summary>
    public class cgdl : System.Web.UI.Page
    {
    protected System.Data.OleDb.OleDbConnection myConnection;
    protected System.Data.OleDb.OleDbCommand myCommand;
    protected System.Web.UI.WebControls.Label xuehao;
    protected System.Web.UI.WebControls.Label Label2;
    protected System.Web.UI.WebControls.Label Label3;
    protected System.Web.UI.WebControls.Label xingming;
    protected System.Web.UI.WebControls.Label Label5;
    protected System.Web.UI.WebControls.Label mima;
    protected System.Web.UI.WebControls.Label Label7;
    protected System.Web.UI.WebControls.Label tswt;
    protected System.Web.UI.WebControls.Label Label9;
    protected System.Web.UI.WebControls.Label hdwt;
    protected System.Web.UI.WebControls.Label Label11;
    protected System.Web.UI.WebControls.HyperLink HyperLink1;
    protected System.Web.UI.WebControls.Label Label4;
             protected System.Data.OleDb.OleDbDataReader myReader;
      

  5.   

    using System.Data.SqlClient;
    private void Page_Load(object sender, System.EventArgs e) 
    {
    string myConn= "Server=(local);DataBase=material;UID=sa;PWD=";  
    string mySelectQuery ="SELECT * FROM mima where 学号='"+Request.QueryString["xuehao"]+"'";
    SqlConnection myConnection = new SqlConnection(myConn);
    SqlCommand myCommand = new SqlCommand(mySelectQuery,myConnection);
    myConnection.Open();
    SqlDataReader myReader = new SqlDataReader( );
    myReader= myCommand.ExecuteReader();
    Always call Read before accessing data.
    while (myReader.Read()) {
                    this.xuehao.Text=myReader["学号"].ToString();
                    this.xingming.Text=myReader["姓名"].ToString();
                    this.mima.Text=myReader["密码"].ToString();
                    this.tswt.Text=myReader["提示问题"].ToString();
                    this.hdwt.Text=myReader["回答问题"].ToString();
    }
    // always call Close when done reading.
           this.myReader.Close();
    // Close the connection when done with it.
           this.myConnection.Close();
    }
      

  6.   

    按照
    coldljy(凤舞N天)
    的说法编译现在没有发现错误了
    谢谢大家,结帖。
      

  7.   

    你看样做啊,晕protected System.Data.OleDb.OleDbConnection myConnection;
    protected System.Data.SqlClient.SqlCommand myCommand;
    protected System.Web.UI.WebControls.Label xuehao;
    protected System.Web.UI.WebControls.Label Label2;
    protected System.Web.UI.WebControls.Label Label3;
    protected System.Web.UI.WebControls.Label xingming;
    protected System.Web.UI.WebControls.Label Label5;
    protected System.Web.UI.WebControls.Label mima;
    protected System.Web.UI.WebControls.Label Label7;
    protected System.Web.UI.WebControls.Label tswt;
    protected System.Web.UI.WebControls.Label Label9;
    protected System.Web.UI.WebControls.Label hdwt;
    protected System.Web.UI.WebControls.Label Label11;
    protected System.Web.UI.WebControls.HyperLink HyperLink1;
    protected System.Web.UI.WebControls.Label Label4;
             protected System.Data.SqlClient.SqlDataReader myReader;