当输入到我的 SQL 客户端时,这方面的 SQL 工作得很好。但是,当我尝试在 csharp 中以编程方式执行此操作时,不会返回任何数据。数据被添加到 follow_fb_threads 表中,但是当我尝试从数据读取器读取时出现错误。它告诉我我的数据为空。
SqlDataReader dr;
using (cmd = new SqlCommand("INSERT INTO followups_fb_threads (thread_id, thread_time, sender_name, sender_fb_id, sender_location) VALUES (@thread_id, @thread_time, @sender_name, @sender_fb_id, @sender_location); SELECT SCOPE_IDENTITY() AS [SCOPE_IDENTITY];", con)) ;
cmd.Parameters.Add(new SqlParameter("thread_id", thread_id));
cmd.Parameters.Add(new SqlParameter("thread_time", thread_time));
cmd.Parameters.Add(new SqlParameter("sender_name", sender_name));
cmd.Parameters.Add(new SqlParameter("sender_fb_id", master_sender_fb_id));
cmd.Parameters.Add(new SqlParameter("sender_location", sender_location));
dr = cmd.ExecuteReader();
string type_id = dr[0].ToString(); // YOU SHOULD HAVE DATA BUT IS NULL? WTH?