3 回答
TA贡献1828条经验 获得超3个赞
您不是在初始化连接,这就是为什么出现这种错误的原因。
您的代码:
cmd.InsertCommand = new SqlCommand("INSERT INTO Application VALUES (@EventLog, @TimeGenerated, @EventType, @SourceName, @ComputerName, @InstanceId, @Message) ");
更正的代码:
cmd.InsertCommand = new SqlCommand("INSERT INTO Application VALUES (@EventLog, @TimeGenerated, @EventType, @SourceName, @ComputerName, @InstanceId, @Message) ",connection1);
TA贡献1880条经验 获得超4个赞
您不是在初始化连接,这就是为什么出现这种错误的原因。
您的代码:
cmd.InsertCommand = new SqlCommand("INSERT INTO Application VALUES (@EventLog, @TimeGenerated, @EventType, @SourceName, @ComputerName, @InstanceId, @Message) ");
更正的代码:
cmd.InsertCommand = new SqlCommand("INSERT INTO Application VALUES (@EventLog, @TimeGenerated, @EventType, @SourceName, @ComputerName, @InstanceId, @Message) ",connection1);
- 3 回答
- 0 关注
- 984 浏览
添加回答
举报