public bool AddFeedBack(Guid UserID, int F_Type,
int F_Status,
string F_Content,
string F_SenderName,
string F_ProductImageUrl)
{
try
{
DALDataContext ocDC = new DALDataContext(ConfigurationManager.ConnectionStrings["OfficeChannelConnectionString_Web"].ConnectionString); FeedBack FB = new FeedBack();
Guid F_ID = Guid.NewGuid();
FB.F_ID = F_ID;
FB.F_UserID = UserID; //为什么这里不执行呢?其他得执行也不报错。其他得都能写入数据库,唯独这个不执行。
FB.F_Type = F_Type;
FB.F_DateTime = DateTime.Now;
FB.F_Status = F_Status;
FB.F_Content = F_Content;
FB.F_SenderName = F_SenderName;
FB.F_ProductImageUrl = F_ProductImageUrl;
ocDC.FeedBack.InsertOnSubmit(FB);
ocDC.SubmitChanges();
return true;
}
catch (Exception e)
{
Console.WriteLine(e);
return false;
}
}
你的UserID是什么类型?它是不是GUID格式的(即:xxxx-xxx....)?和加大括号没关系的,如果你的UserID是String类型的话可以直接Guid userid=new Guid(UserID)这样进行转换的
int F_Status,
string F_Content,
string F_SenderName,
string F_ProductImageUrl)
{
try
{
DALDataContext ocDC = new DALDataContext(ConfigurationManager.ConnectionStrings["OfficeChannelConnectionString_Web"].ConnectionString); FeedBack FB = new FeedBack();
Guid F_ID = Guid.NewGuid();
FB.F_ID = F_ID;
FB.F_UserID = UserID; //为什么这里不执行呢?其他得执行也不报错。其他得都能写入数据库,唯独这个不执行。
FB.F_Type = F_Type;
FB.F_DateTime = DateTime.Now;
FB.F_Status = F_Status;
FB.F_Content = F_Content;
FB.F_SenderName = F_SenderName;
FB.F_ProductImageUrl = F_ProductImageUrl;
ocDC.FeedBack.InsertOnSubmit(FB);
ocDC.SubmitChanges();
return true;
}
catch (Exception e)
{
Console.WriteLine(e);
return false;
}
}你这时候的UserID根本没赋值,它的值为Null,所以FB.F_UserID = UserID;执行了FB.F_UserID也是没值的