System.Data.Odbc.OdbcConnection con = new System.Data.Odbc.OdbcConnection(@"Driver={Microsoft Access Driver (*.mdb)};DBQ=F:\project\TyhGallery\db.mdb");
        con.Open();
        System.Data.Odbc.OdbcCommand cmd = new System.Data.Odbc.OdbcCommand("select * from users where user_name='" + name + "' and user_password='" + pwd + "'", con);
        System.Data.Odbc.OdbcDataReader reader = cmd.ExecuteReader();
        if (reader.Read())
        { return true; }
        else
        { return false; } 网上很多的 建议搜索下

解决方案 »

  1.   

    可是会出错啊!!有关调用实时(JIT)调试而不是此对话框的详细信息,
    请参见此消息的结尾。************** 异常文本 **************
    System.TypeInitializationException: “System.Transactions.Diagnostics.DiagnosticTrace”的类型初始值设定项引发异常。 ---> System.Configuration.ConfigurationErrorsException: 配置系统未能初始化 ---> System.Configuration.ConfigurationErrorsException: 配置文件 CallNumber.exe.config 没有根 <configuration> 标记 (D:\MyJob\Item\PR3\CallNumber\bin\Debug\CallNumber.exe.config line 2)
       在 System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
       在 System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors)
       在 System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors()
       在 System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
       --- 内部异常堆栈跟踪的结尾 ---
       在 System.Configuration.ConfigurationManager.GetSection(String sectionName)
       在 System.Configuration.PrivilegedConfigurationManager.GetSection(String sectionName)
       在 System.Diagnostics.DiagnosticsConfiguration.GetConfigSection()
       在 System.Diagnostics.DiagnosticsConfiguration.Initialize()
       在 System.Diagnostics.DiagnosticsConfiguration.get_Sources()
       在 System.Diagnostics.TraceSource.Initialize()
       在 System.Diagnostics.TraceSource.get_Switch()
       在 System.Transactions.Diagnostics.DiagnosticTrace..cctor()
       --- 内部异常堆栈跟踪的结尾 ---
       在 System.Transactions.Transaction.get_Current()
       在 System.Data.Common.ADP.IsSysTxEqualSysEsTransaction()
       在 System.Data.Common.ADP.NeedManualEnlistment()
       在 System.Data.Odbc.OdbcConnection.Open()
       在 CallNumber.Form1.Form1_Load(Object sender, EventArgs e) 位置 D:\MyJob\Item\PR3\CallNumber\Form1.cs:行号 55
       在 System.Windows.Forms.Form.OnLoad(EventArgs e)
       在 System.Windows.Forms.Form.OnCreateControl()
       在 System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       在 System.Windows.Forms.Control.CreateControl()
       在 System.Windows.Forms.Control.WmShowWindow(Message& m)
       在 System.Windows.Forms.Control.WndProc(Message& m)
       在 System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       在 System.Windows.Forms.ContainerControl.WndProc(Message& m)
       在 System.Windows.Forms.Form.WmShowWindow(Message& m)
       在 System.Windows.Forms.Form.WndProc(Message& m)
       在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)