我試圖用兩個表連接到數據庫。但是,在我嘗試登錄後,出現錯誤。錯誤表示零點沒有行。我認爲這是因爲我的連接任何幫助,將不勝感激。與OleDbConnection連接
感謝先進!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.OleDb;
namespace Project3
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void login_Click(object sender, EventArgs e)
{
OleDbConnection connect = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Users\\parodeghero\\Documents\\Visual Studio 2010\\Projects\\Project3\\Project3\\App_Data\\QA.mdb;Persist Security Info=True");
//set up connection string
OleDbCommand command = new OleDbCommand("select * from Employee where [email protected]", connect);
OleDbParameter param0 = new OleDbParameter("@login", OleDbType.VarChar);
param0.Value = employeeID.Text;
command.Parameters.Add(param0);
//middle tier to run connect
OleDbDataAdapter da = new OleDbDataAdapter(command);
DataSet dset = new DataSet();
da.Fill(dset);
//problem line
if (dset.Tables[0].Rows[0]["Password"].ToString().Equals(password.Text))
{
如何調用'開()'對於初學者的連接? – 2012-03-22 23:09:44
謝謝!我想我需要一個嘗試和捕獲聲明我的OleDbCommand太! – asguy 2012-03-22 23:17:51
我回到原來的標題。如果您對自己的問題有自己的答案,請將其作爲答案張貼並接受。請不要使用「已解決」編輯標題,也不要使用答案編輯問題。 – LarsTech 2012-03-22 23:25:48