62,074
社区成员
发帖
与我相关
我的任务
分享
SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["qds177479644_dbConnectionString"].ConnectionString);
//String insertStr = String.Format("insert into NoodleShopInfo([Userid],[类别],[面坊所在地],[适宜人数],[面坊简介],[推广]) values('{0}','{1}','{2}','{3}','{4}','{5}')", Session["Userid"].ToString(), "求购", 省份DropDownList.SelectedItem.Text, 适宜人数TextBox.Text,面坊简介TextBox.Text, 推广CheckBox.Checked);
String insertStr = String.Format("insert into NoodleShopInfo([Userid],[类别],[面坊所在地],[适宜人数],[面坊简介],[推广]) values('{0}','{1}','{2}','{3}','{4}','{5}') SELECT @@IDENTITY", Session["Userid"].ToString(), "求购", 省份DropDownList.SelectedItem.Text, 适宜人数TextBox.Text, 面坊简介TextBox.Text, 推广CheckBox.Checked);
SqlCommand cmd = new SqlCommand(insertStr, con);
try
{
con.Open();
//if(cmd.ExecuteNonQuery()>0)
// Response.Redirect("~/Account/MyRelease");
Response.Write("Id:"+cmd.ExecuteScalar().ToString());
}
catch (Exception ERR)
{
Response.Write(ERR.Message.ToString());
}
finally
{
con.Close();
}