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;
            }
        }

解决方案 »

  1.   

     FB.F_UserID在表里是这个类型uniqueidentifier ,F_id不用转换怎么他就要转换到底为啥,,,,
      

  2.   

    ~uniqueidentifier插入加个大括号看看的~~string strSql = "insert into [News_Re] values('{" + System.Guid.NewGuid().ToString() + "}','" + System.DateTime.Now + "')";
      

  3.   

    什么是要转换?你的F_UserID在实体类中本来就是GUID类型的
    你的UserID是什么类型?它是不是GUID格式的(即:xxxx-xxx....)?和加大括号没关系的,如果你的UserID是String类型的话可以直接Guid userid=new Guid(UserID)这样进行转换的
      

  4.   

     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根本没赋值,它的值为Null,所以FB.F_UserID = UserID;执行了FB.F_UserID也是没值的
      

  5.   

    把代码放到try外面再运行看详细错误。