OleDbConnection Conn = new OleDbConnection(Connect1);            OleDbDataAdapter da = new OleDbDataAdapter();            da.SelectCommand.CommandText = "select * from [user] where uidname=@uidname and pwdword=@pwdword" ;            da.SelectCommand.Parameters.Add("@uidname",SqlDbType.VarChar);
            da.SelectCommand.Parameters["@uidname"].Value = TextBox1.Text;
            da.SelectCommand.Parameters.Add("@pwdword",SqlDbType.VarChar);
            da.SelectCommand.Parameters["@pwdword"].Value = TextBox2.Text;
            DataSet ds1 = new DataSet();            da.Fill(ds1,"dg1");            Response.Write(ds1.Tables["dg1"].DefaultView.Count);            Conn.Close();
提示: 
da.SelectCommand.CommandText = "select * from [user] where uidname=@uidname and pwdword=@pwdword" ; 
未将对象引用设置到对象的实例。

解决方案 »

  1.   

     参考
    SqlCommand cmd = new SqlCommand("insert into tbl_Question(course,question,point,ken,type,[delete]) values(@course,@question,@point,@ken,@type,@delete);select @id = scope_identity()", cn);
                    cmd.Transaction = ta;
                    cmd.Parameters.Add("@id", SqlDbType.Int).Direction = ParameterDirection.Output;
                    cmd.Parameters.AddWithValue("@course", Request.QueryString["course"]);
                    cmd.Parameters.AddWithValue("@question", txtQuestion.Text.Trim());
                    cmd.Parameters.AddWithValue("@point", dropPoint.SelectedValue);
                    cmd.Parameters.AddWithValue("@ken", dropKen.SelectedValue);
                    cmd.Parameters.AddWithValue("@type", Request.QueryString["type"]);
                    cmd.Parameters.AddWithValue("@delete", 0);
      

  2.   

    da.SelectCommand没有被实例化,需要new一个出来。OleDbDataAdapter adapter = new OleDbDataAdapter();
        OleDbCommand command;    // Create the SelectCommand.
        command = new OleDbCommand("SELECT * FROM Customers " +
            "WHERE Country = ? AND City = ?", connection);    command.Parameters.Add("Country", OleDbType.VarChar, 15);
        command.Parameters.Add("City", OleDbType.VarChar, 15);    adapter.SelectCommand = command;    // Create the InsertCommand.
        command = new OleDbCommand(
            "INSERT INTO Customers (CustomerID, CompanyName) " +
            "VALUES (?, ?)", connection);    command.Parameters.Add(
            "CustomerID", OleDbType.Char, 5, "CustomerID");
        command.Parameters.Add(
            "CompanyName", OleDbType.VarChar, 40, "CompanyName");    adapter.InsertCommand = command;
        return adapter;参见:
    http://msdn.microsoft.com/en-us/library/system.data.oledb.oledbdataadapter.selectcommand.aspx
      

  3.   

    OleDbCommand  cmd=new OleDbCommand ("select * from [user] where uidname=@uidname and pwdword=@pwdword" ,con);