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" ;
未将对象引用设置到对象的实例。
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" ;
未将对象引用设置到对象的实例。
解决方案 »
- 如何在C#.NET中创建一个程序的LOGO窗体?
- 大家来谈谈设计模式——工厂
- C#2个文本的对比
- sqlCommand1.ExecuteNonQuery();执行出错
- 请问在DataTable的select方法中能不能指定返回行数?
- vs2008文件打包,为什么有时候会把.net3.5打进去
- "window.history.back(-1)"是不是跟用鼠标点"后退"的效果一样呀?
- SQL SERVER语句问题已经纠结好久了,跪求大神指点 ...
- C# tabControl 关闭窗口的界面切换问题。
- DataGrid中的数据如何打印出来~!
- 求助:vs2005(C#)怎么建立框架?
- 怎样把数据库中int型数据绑定到textbox中?
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);
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