尝试在C#中插入已发布到数据库中页面的数据。当我将其写入文件时,我可以看到发布的数据。但是,当我尝试将其插入表格时,它不会插入它。但是,如果不使用发布的数据,我会使用它插入的硬代码数据。我无法调试这个,因为发布的数据只有在我上传到服务器时才会发布到页面。但插入部分是工作文件,我尝试使用测试数据。
这是我的代码:
if (Request.HttpMethod.ToString() == "POST")
{
StreamWriter sw = new StreamWriter(@"C:\IIS\wwwroot\MailGun\text.txt");
sw.Write("You sent a post!" + "recipient: " + Request["recipient"] + "event: " + Request["event"] );
//here it is writing posted data in file and I check it is there.
sw.Close();
recipient = Request["recipient"]; //this is where I have problem I think.
event1 = Request["event"];
InsertWebhook();
}
protected void InsertWebhook()
{
Webhookfields webhookfields = new Webhookfields();
webhookfields.event =event1;
webhookfields.recipient =recipient;
webhookfields = DataManager.InsertWebhook(webhookfields);
}
public string recipient { get; set; }
public string event1 { get; set; }
如果不是这个,我使用这个代码就是插入:
string recipient = "recipient test";
string event1 = "event test"
InsertWebhook();
我发现了问题。在要插入的存储过程中,我必须标识默认的Null值。它现在正在插入。
答案 0 :(得分:-1)
我发现了问题。在要插入的存储过程中,我必须标识默认的Null值。它现在正在插入。