asp.net高手请看.... OleDbCommand cmd = new OleDbCommand("insert into ProductTbl(ProductName,ProductContent) values(@ProductName,@ProductContent)", conn);SQL语句里的@代表什么意思? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这表示@ProductName,@ProductContent是参数可以通过OleDbParameter来传递参数具体请用百度搜索OleDbParameter在SQL中是这样的,你可以参考:SqlParameter param1=new SqlParameter("@ProductName",VarChar,200);param1.Value=你要插入的值SqlParameter param2=new SqlParameter("@ProductContent",VarChar,200);param2.Value=你要插入的值 @procuctname这是TSQL的语法,代表一个变量.不过写在这里好像有问题,没法用啊! public static bool Update(int productID, string productName,string productContent) { OleDbConnection conn = new OleDbConnection(connectString); OleDbCommand cmd = new OleDbCommand("update ProductTbl set ProductName='" + productName.Replace("'","''") + "',ProductContent='"+productContent+"' where ProductID=@ProductID", conn); cmd.Parameters.Add("@ProductID",OleDbType.Integer); cmd.Parameters["@ProductID"].Value = productID; ......productName,productContent也是参数,为什么么他们在new OleDbCommand(...,里不用加@前缀? public string connectString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+HttpContext.Current.Server.MapPath("Data/Test.mdb");变量connectString值前加@,这样说明了什么? public string connectString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+HttpContext.Current.Server.MapPath("Data/Test.mdb");这个@是特殊字符抑制符,比如你要一个字符串"c:\test.txt",一般要这样写string s = "c:\\test.txt",但你也可以写成这样:string s = @"c:\test.txt"@就是抑制了\的转义功能 求助:在.net中对于xml的用法 奇怪的VS03项目,求解 C# 工厂模式反射引用问题 问个改变字符格式问题 如何用dataTable的select()方法找出某列不为null的所以DataRow. ASP.NET的WEB获取IP时无论用什么语句,获得的总是服务器本身的IP.求解,谢谢 那里有经典的源代码啊? 什么原因引起这个错误? 简单问题:关于删除前的提示信息,例如:确认删除吗? TD比图片大,怎么样把TD变小 哪位有书 ASP_NET.XML高级编程-C#编程篇 的源码 请教一下各位网站开发的收费问题?
可以通过OleDbParameter来传递参数
具体请用百度搜索OleDbParameter
在SQL中是这样的,你可以参考:
SqlParameter param1=new SqlParameter("@ProductName",VarChar,200);
param1.Value=你要插入的值
SqlParameter param2=new SqlParameter("@ProductContent",VarChar,200);
param2.Value=你要插入的值
不过写在这里好像有问题,没法用啊!
{
OleDbConnection conn = new OleDbConnection(connectString);
OleDbCommand cmd = new OleDbCommand("update ProductTbl set ProductName='" + productName.Replace("'","''") + "',ProductContent='"+productContent+"' where ProductID=@ProductID", conn);
cmd.Parameters.Add("@ProductID",OleDbType.Integer);
cmd.Parameters["@ProductID"].Value = productID;
......
productName,productContent也是参数,为什么么他们在new OleDbCommand(...,里不用加@前缀?
这个@是特殊字符抑制符,比如你要一个字符串"c:\test.txt",一般要这样写
string s = "c:\\test.txt",
但你也可以写成这样:
string s = @"c:\test.txt"
@就是抑制了\的转义功能