IM使用MS Access数据库中,我有2表1配方和第二个1是我的id字段是自动编号类型在评论这是文本,并在插入时间从IM retreiving配方ID意见comments.in配方配方表,因此,如何转换成字符串,ID,这样我就可以插入exmple-GT,在意见表中的id ....
DateTime currdate = DateTime.Now.Date;
connection();
OleDbCommand cmd1 = new OleDbCommand("select ID from addrecipes where [IsActive]=yes", con);
OleDbDataReader dr;
dr = cmd1.ExecuteReader();
if (dr.Read())
{
session["recid"] = dr["ID"].ToString();
}
OleDbCommand cmd = new OleDbCommand("insert into addcomment (Uname,dname,comment,datecomment,uid,ID,IsActive) values('" + Session["uid"].ToString() + "','" + Session["txtfullname"].ToString() + "','" + txtdesc.Text + "','" + currdate + "','" + Session["idd"].ToString() + "','"+session["recid"].ToString()+"','Yes')", con);
cmd.ExecuteNonQuery();
con.Close();
ScriptManager.RegisterStartupScript(this, this.GetType(), "Success", "<script>alert('Post Added Successfully');window.location.href ='recipes.aspx'; </script>", false);