我在c#中有以下代码,我收到编译错误.谁能帮帮我吗?
更新
protected void Page_Load(object sender, EventArgs e)
{
OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=|DataDirectory|OID.mdb;Persist Security Info=False;");
//OleDbConnection con = new OleDbConnection("Data Source=sml; User ID=sml; Password=sml; provider=OraOLEDB.Oracle");
OleDbCommand cmd = new OleDbCommand();
//cmd.CommandText = "Select * from EMAILS WHERE EMAIL= '" + GlobalData.Email + "'";
cmd.CommandText = "Select * from EMAILS";
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
foreach (DataRow row in ds.Tables[0].Rows)
{
String email = row["email"].ToString();
if (email == GlobalData.Email)
{
Label2.Text = GlobalData.Email;
Label1.Text = GlobalData.Name;
Label3.Text = GlobalData.LastName;
}
else
{
Response.Redirect("login.aspx");
}
}
}
Run Code Online (Sandbox Code Playgroud)
现在它在循环之后直接进入else部分,现在将出现错误
你用的是(代替[.
for (I = 0; I <= ds.Tables["EMAILS"].Rows.Count - 1; I++)
{
String email = ds.Tables["EMAILS"].Rows[I].Item["email"];
Run Code Online (Sandbox Code Playgroud)