int flag=0;
Connection.Open();
string sql="insert into MsgInfo(title,content,sendtime) values('"+bVO.Subject+"','"+bVO.Content+"','"+bVO.Fbtime+"')";
SqlCommand sqlComm = new SqlCommand(sql,Connection);
flag = sqlComm.ExecuteNonQuery();
sql="select @@identity as id from MsgInfo";
sqlComm = new SqlCommand(sql,Connection);
SqlDataReader tmpReader = sqlComm.ExecuteReader();
if(tmpReader.Read())
{
flag = Convert.ToInt32(tmpReader["id"].ToString());
}
Connection.Close();
return flag;
|
请发表评论