![](/img/trans.png)
[英]How to break up a huge service.cs file into multiple smaller services?
[英]Error when trying to view the Service.cs in browser and using this activity
我总是收到这个错误:
没有为一个或多个必需参数指定值。
这是我的 C# 代码:
[WebMethod]
public string AddNews(string time1, string content,string topic)
{
string strSql = String.Format("insert into [News] ([time],[content],[topic]) values (" + time1 + " , " + content + " , " + topic + " )");
DAL.ChangeTable(strSql);
return "News added Successfully";
}
先说第一件事。 此代码对 SQL 注入 ( https://en.wikipedia.org/wiki/SQL_injection ) 开放,不应使用。 其次,该消息表明您没有提供所需的输入。 我会检查是否有一个包含更多细节的内部异常。
使用SQL 参数
并在字符串中添加 '
string strSql = String.Format("INSERT INTO [News] ([time], [content], [topic]) VALUES ('" + time1 + "' , '" + content + "' , '" + topic + "' )");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.