1
我我,当我使用这些代码使用VS2008和SQLLite.Net, :如何参数添加到Sqllitecommand
String sel = "select * from admins where [name]='admin88' and [password]='123456'";
System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection();
conn.ConnectionString = Config.connStr;
conn.Open();
System.Data.SQLite.SQLiteCommand cmd = new System.Data.SQLite.SQLiteCommand();
cmd.CommandText = sel;
cmd.CommandType = CommandType.Text;
cmd.Connection = conn;
DataSet set = new DataSet();
System.Data.SQLite.SQLiteDataAdapter adp = new System.Data.SQLite.SQLiteDataAdapter() ;
adp.SelectCommand = cmd;
adp.Fill(set);
adp.Dispose();
Response.Write(set.Tables.count);
它的工作原理。 但是当我使用的参数,返回null:
String sel = "select * from admins where [name][email protected] and [password][email protected]";
cmd.Parameters.Clear();
cmd.Parameters.Add(new System.Data.SQLite.SQLiteParameter("@name", "admin88"));
cmd.Parameters.Add(new System.Data.SQLite.SQLiteParameter("@pass", "123456"));
感谢Niranjan Kala.that很有帮助! – 2012-03-22 05:40:24