日期:2014-05-18 浏览次数:20579 次
//if (!Page.IsValid) // return; //MembershipUser member= Membership.GetUser(); //Guid currentUserId=(Guid)member.ProviderUserKey; //string conn = // ConfigurationManager.ConnectionStrings["SecurityTutorialsConnectionString"].ConnectionString; //string insertsql = "Insert into GuestbookComments(Subject,Body,UserId) values(@Subject,@Body,@UserId)"; //using (SqlConnection myConnection = new SqlConnection(conn)) //{ // myConnection.Open(); // SqlCommand cmd = new SqlCommand(insertsql, myConnection); // cmd.Parameters.AddWithValue("@UserId", currentUserId); // cmd.Parameters.AddWithValue("@Subject", Subject.Text.Trim()); // cmd.Parameters.AddWithValue("@Body", Body.Text.Trim()); // cmd.ExecuteNonQuery(); // myConnection.Close(); //} //Subject.Text = null; //Body.Text = null;