using (SqlConnection conn = DB.crteatConn()) { using (SqlCommand cmd = new SqlCommand()) { cmd.Parameters.Add("@userName", SqlDbType.NVarChar, 20).Value = HiddenField1.Value; cmd.Parameters.Add("@DateTime", SqlDbType.NVarChar, 8).Value = DateTime.Now.ToString(); cmd.Parameters.Add("@Message", SqlDbType.NVarChar, 150).Value = txtMessage.Text; cmd.CommandText = "insert into ChatRoom values(@userName,@DateTime,@Message)"; cmd.Connection = conn; conn.Open(); cmd.ExecuteNonQuery(); } |
|
來自: 悟靜 > 《數(shù)據(jù)庫》