恩 视频里有讲的 比如像这样
string sql = "insert into Admin(UserName,Password)values(@UserName,@Password)";
SqlConnection conn = new SqlConnection();
conn.ConnectionString = ".......";
SqlCommand com = new SqlCommand(sql, conn);
com.Parameters.Add(":UserName",SqlDbType.NVarChar, 60).Value = userName;
com.Parameters.Add(":Password", SqlDbType.NVarChar, 60).Value = password;
conn.Open();
int rowsAffected = com.ExecuteNonQuery();
conn.Close();
com.Dispose(); |