soheila2012
یک شنبه 29 اردیبهشت 1392, 22:51 عصر
این کد برای دکمه ی ثبت نوشتم که باید تو Databaseم که Access هست قرار بگیره و داخل صفحه ی دیگه وقتی Dataview میزارم بتونه از Database بخونه ولی نمیشه!!
protected void btnSubmit_Click(object sender, EventArgs e)
{
con.Open();
// int NID = Convert.ToInt32(ViewState["NID"]);
if ((txtName.Text == "" || txtEmail.Text == "") && txtComment.Text == "")
{
lblResult.ForeColor = System.Drawing.Color.Red;
lblResult.Text = " خطا در ارسال پيام، لطفا دوباره سعی کنید ";
lblResult.Visible = true;
}
else
{
string query = "insert into tblComment(commentUserName,CommentEmail,CommentTex t)VALUES ('" + txtName.Text + "','" + txtEmail.Text + "','" + txtComment.Text + "')";
OleDbCommand da = new OleDbCommand();
da.CommandText = query;
da.Connection = con;
// da.ExecuteNonQuery();
con.Close();
lblResult.Text = "پيام شما با موفقيت ارسال شد .";
lblResult.ForeColor = System.Drawing.Color.Green;
lblResult.Visible = true;
btnSubmit.Enabled = false;
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
con.Open();
// int NID = Convert.ToInt32(ViewState["NID"]);
if ((txtName.Text == "" || txtEmail.Text == "") && txtComment.Text == "")
{
lblResult.ForeColor = System.Drawing.Color.Red;
lblResult.Text = " خطا در ارسال پيام، لطفا دوباره سعی کنید ";
lblResult.Visible = true;
}
else
{
string query = "insert into tblComment(commentUserName,CommentEmail,CommentTex t)VALUES ('" + txtName.Text + "','" + txtEmail.Text + "','" + txtComment.Text + "')";
OleDbCommand da = new OleDbCommand();
da.CommandText = query;
da.Connection = con;
// da.ExecuteNonQuery();
con.Close();
lblResult.Text = "پيام شما با موفقيت ارسال شد .";
lblResult.ForeColor = System.Drawing.Color.Green;
lblResult.Visible = true;
btnSubmit.Enabled = false;
}
}