The following function works fine.
public int AddRecord(String MsgTo, String MsgFrom, String MsgCC, String MsgBC, DateTime DateSent)
{
SqlParameter[] sqlParams = new SqlParameter[] {
new SqlParameter("@MsgTo", MsgTo),
new SqlParameter("@MsgFrom", MsgFrom),
new SqlParameter("@MsgCC", MsgCC),
new SqlParameter("@MsgBC", MsgBC),
new SqlParameter("@DateSent", DateSent),
};
return logContactUsMessage.insertMessage(sqlParams);
}
However, when I try and add the dbtype and length, VS2010 says all is ok and compiles, but the code won't run in the browser. I also cannot find any web examples using this format, even though autocomplete tells me it is correct and valid.
public int AddRecord(String MsgTo, String MsgFrom, String MsgCC, String MsgBC, DateTime DateSent)
{
SqlParameter[] sqlParams = new SqlParameter[] {
new SqlParameter("@MsgTo", SqlDbType.VarChar, 250, "MsgTo"),
new SqlParameter("@MsgFrom", SqlDbType.VarChar, 250, "MsgFrom"),
new SqlParameter("@MsgCC", SqlDbType.VarChar, 250, "MsgCC"),
new SqlParameter("@MsgBC", SqlDbType.VarChar, 250, "MsgBC"),
new SqlParameter("@DateSent", SqlDbType.DateTime, 8, "DateSent"),
};
return logContactUsMessage.insertMessage(sqlParams);
}