一旦用户登录帐户并填写表格...表格信息存储到数据库..但如何将该数据存储在特定登录的用户帐户中?
如何在登录用户帐户中存储表单数据?
下面的代码是表单提交按钮:
protected void submit_Button_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Documents and Settings\pragmatic\Desktop\mvcapplication\MvcApplication1\MvcApplication1\App_Data\custresponse.mdf;Integrated Security=True;User Instance=True");
//s = WebConfigurationManager.ConnectionStrings["ChartDatabaseConnectionString"].ConnectionString;
//con = new SqlConnection(s);
con.Open();
//date = day_DropDownList.Text.ToString() + "/" + month_DropDownList.Text.ToString() + "/" + year_DropDownList.Text.ToString();
cmd = new SqlCommand("insert into custresponse values('" + title_Txt.Text + "','" + description_Txt.Text + "','" + money + "','" + Convert.ToDateTime(txtDate.Text).ToString("dd-MMM-yyyy") + "','" + money1_Txt.Text + "')", con);
cmd.ExecuteNonQuery();
Label1.Text = "Information submitted successfully";
con.Close();
clear();
}
答案 0 :(得分:0)
如果您可以修改表格,则在表格中添加一列。该列将充当指示用户身份的标志。现在只需传递cookie对象(如果在用户登录期间创建),或将用户登录ID作为参数传递给SQL数据库。
其他明智地使用任何分隔符(如pipe(||)符号)将“title_Txt”附加到用户登录ID。稍后,在检索title_Txt时,会根据分隔符拆分内容并返回用户登录ID。