我无法将检索到的数据绑定到标签中。我将从标签创建一个会话变量,数据是最近新记录的supplierid 这里是.cs文件
protected void InsertSupplier(object sender, EventArgs e)
{
OleDbConnection mDB = new OleDbConnection();
mDB.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data source="
+ Server.MapPath("~/App_Data/IESDatabase.accdb");
OleDbCommand cmd;
string strSQLInsert = "INSERT INTO "
+ " Supplier (sName, sPhone, sAddress, sCompany, sStatus)"
+ " VALUES (@name, @phone, @add, @co, @status)";
mDB.Open();
cmd = new OleDbCommand(strSQLInsert, mDB);
cmd.Parameters.AddWithValue("@name", txtfullname.Text);
cmd.Parameters.AddWithValue("@phone", Phone.Text);
cmd.Parameters.AddWithValue("@add", txtaddress.Text);
cmd.Parameters.AddWithValue("@co", CompanyNameBox.Text);
cmd.Parameters.AddWithValue("@status", lblStatus.Text);
cmd.ExecuteNonQuery();
mDB.Close();
/*
OleDbDataReader rdr;
string strSQLSelect = "SELECT sSupplierId FROM Supplier ORDER BY sSupplierId";
mDB.Open();
cmd = new OleDbCommand(strSQLSelect, mDB);
rdr = cmd.ExecuteReader();
while (rdr.Read() == true)
{
lblSupplier.Text = rdr["sSupplierId"].ToString();
}
Session["sSupplierId"] = (string)lblSupplier.Text;
*/
MessageBox.Show("Insert New Supplier is successful", "Admin");
Response.Redirect("Adminpage.aspx");
}