OleDbCommand cmd = new OleDbCommand();
OleDbConnection conn=new OleDbConnection();
string sqlstring="select * forums_users where username='lz'";
conn.ConnectionString="Provider=Microsoft.Jet.OleDb.4.0;Data Source="+System.Web.HttpContext.Current.Server.MapPath("./Data.mdb");
cmd.Connection=conn; cmd.Connection.Open();
cmd.CommandType=CommandType.Text;
cmd.CommandText=sqlstring;
int retval = cmd.ExecuteNonQuery();
if(cmd.Connection.State==ConnectionState.Open)
cmd.Connection.Close();运行的时候说:"select * forums_users where username='lz'" 变成了
"* forums_users where username='lz'" 为什么?

解决方案 »

  1.   

    select *  from forums_users where username='lz'
      

  2.   

    string sqlstring="select * forums_users where username='lz'";
    那这个语句肯定是不对的,只要没有from 这个关键字。
      

  3.   

    "select * forum s_users where username='lz'"
      

  4.   

    from 啦,呵呵,以前我经常把from 写成form
      

  5.   

    hehe手误把 少了from 关键字
      

  6.   

    select * from forums_users where username='lz'
      

  7.   

    select * from forums_users where username='lz'
      

  8.   

    来晚了select * from forums_users where username='lz'
      

  9.   

    删除语句又怎么写呢?我的也老是出现以上错误!
    string   sqlstring= "delete " + tablename + " where 编号='" + j + "' and 工作期编号='" + wid+"'"; 
    哪里有误?大侠们帮忙看看啊