pass='"+textBox2.Text+"";   这个sql语句后面不应该是"" 应该是"'"吧?

解决方案 »

  1.   

    try:
    检查一下你的数据库中的字段名,是否和程序中的相同;
    或者把你的表名password改为别的试试。
      

  2.   

    错误出现在主程序:
    if(LogForm1.ShowDialog()==DialogResult.OK)
    晕,这个问题困扰我好多天了,谁帮着解决,另外加分!
      

  3.   

    把Sql中的"Password"改成“[Password]”试试。
      

  4.   

    你用try-catch捕获一下,看看具体错误是什么。
      

  5.   

    string mySelectQuery = "SELECT * FROM password where user="+textBox1.Text+" and pass="+textBox2.Text+"";
      

  6.   

    查一下你建的LogForm1窗体中,初始化是不是有不正确的设置.如绑定错误等.
    注意那些不会引起编译错误的问题.试一下吧,可以 单步 调一下啊,应该能发现问题的
      

  7.   

    逐语句运行,程序执行到Rd = myCommand.ExecuteReader();
    便中止了,“未处理的“System.Data.OleDb.OleDbException”类型的异常出现在 system.windows.forms.dll 中”。
      

  8.   

    你的Access數據庫放在哪裏?路徑是什麽?
      

  9.   

    同意 Knight94(愚翁):——        你用try-catch捕获一下,看看具体错误是什么。
      

  10.   

    刚才Try了一下,结果如下
    System.Data.OleDb.OleDbException: 至少一个参数没有被指定值。
       at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr)
       at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
       at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
       at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
       at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
       at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)
       at System.Data.OleDb.OleDbCommand.ExecuteReader()
       at UserManager.LogForm.button1_Click(Object sender, EventArgs e) in e:\vc++\多媒体\usermanager\logform.cs:line 194
      

  11.   

    你在把改后的Sql语句给列出来。
      

  12.   

    检查一下你的string mySelectQuery = "SELECT * FROM password where user='"+textBox1.Text+"' and pass='"+textBox2.Text+"";
    先打开myConnection.Open();
    再执行Rd = myCommand.ExecuteReader();命令,确定是select语句出错还是连接出错
      

  13.   

    to:if(LogForm1.ShowDialog()==DialogResult.OK)
    你如果在LogForm1中定义好DialogResult字段和属性的话,这样
    你就能和MessageBox一样可以获取的DialogResult.OK了吧
      

  14.   

    select user_name,user_password from usercheck where user_name='"+textBox1.text+"' and user_password='"+textBox2.text+"'
      

  15.   

    哈哈!应该是:
    string mySelectQuery = "SELECT * FROM password where user="+"'"+textBox1.Text+"'"+ "and pass="+"'"+textBox2.Text+"'";
    user,pass类型为文本。
    我也困惑了很久!
      

  16.   

    if(form.ShowDialog==DialogResult.OK)出错的话,你可以看看你的form的Load()事件和form的类的问题,ShowDialog会触发form.Load();
      

  17.   

    出错在Rd = myCommand.ExecuteReader();
    估计不是Select语句问题,我曾把select改成Select * from usercheck也是不行,没有碰到这个问题吗?
      

  18.   

    你在Debug是看看myConnection.State,如果是Closed 说明Access的数据库位置不对
      

  19.   

    你先把连接数据库部分用try...catch括一下,看看到底是连接问题还是查询时的问题。别外,你把string mySelectQuery = "SELECT * FROM password where user='"+textBox1.Text+"' and pass='"+textBox2.Text+"";
    加上.Trim()试试,别加错位置!