采用的数据库是access 字段类型全是文本的类型
语句
insert into post ( postid,postname,post_address,sex,country,title,mobile,email,state,postmethod,IsMem,describe )
values
( 'P-1000-45456','45645645645','中国456546','','','456546','','','无退回确认收到','','','') 在vs 调试 老是报insert 语法语句错误 把这个语句在acess 中执行 可以的 找了很长时间 也没发现错在哪里 字段名 好像没有access 中的关键字吧
语句
insert into post ( postid,postname,post_address,sex,country,title,mobile,email,state,postmethod,IsMem,describe )
values
( 'P-1000-45456','45645645645','中国456546','','','456546','','','无退回确认收到','','','') 在vs 调试 老是报insert 语法语句错误 把这个语句在acess 中执行 可以的 找了很长时间 也没发现错在哪里 字段名 好像没有access 中的关键字吧
解决方案 »
- 无奈,跪求各位大哥帮忙解决问题啊!!付费都行啊!
- 太奇怪了,谁能告诉我这是怎么回事?在线等。。。
- 字符转换问题?
- WIN2000 PRO下征求个SQL SERVER2000安装的方案,请大家帮忙!在线等!
- 请问sqlserver 没有有记录每一条执行过的SQL或T-SQL语句的功能???????
- 各位大仙,我想问一个关于聚集索引的问题
- 急啊,sqlserver agent不能启动的问题
- 如何从一个SQL服务器的所有库下删除一个用户?
- 谁用过Oracle8i的UTL_FILE,客户端怎么有错呢?
- 关于sql调用cmd执行的问题
- mssql数据库的系统函数都有哪些
- 如何把sql2000的库导入到sql2005
values
( 'P-1000-45456',
'45645645645',
'中国456546',
'',
'',
'456546',
'',
'',
'无退回确认收到','
',
'',
'')
这乱了
select 'P-1000-45456','45645645645','中国456546','','','456546','','','无退回确认收到','','',''
public class DataAccess
{
public static int ExecuteNonQuery(string CmdText)
{ using (OleDbConnection conn = Get_Connetion())
{
OleDbCommand cmd = conn.CreateCommand();
try
{
conn.Open();
cmd.CommandText = CmdText;
return cmd.ExecuteNonQuery();
}
catch (OleDbException ex)
{
throw new Exception(ex.Message);
}
finally
{
cmd.Dispose();
}
}
} 定义的语句
string strInsert = string.Format("insert into post ( postid,postname,post_address,sex,country,title,mobile,email,state,postmethod,IsMem,describe ) values( '{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}')", drop1.SelectedItem.Value.ToString () + "-" + TextBox1.Text.ToString(), TextBox2.Text + Request.Form["nameE"], Request.Form["post_address"] + Request.Form["txtpost_address"], Request.Form["sex"], Request.Form["country"], Request.Form["title"], TextBox4.Text, TextBox3.Text, Request.Form["effect1"] + Request.Form["effect2"] + Request.Form["record"], Request.Form["post"] + Request.Form["post1"], Request.Form["IsNum"], Request.Form["describe"]);
调用的方法
if (Dal.Dal.DataAccess.ExecuteNonQuery(strInsert) == 1)
{
Response.Write("<script>alert('恭喜,操作成功!')</script>"); }
else
{
Response.Write("<script>alert('操作失败')</script>"); }
public static OleDbConnection Get_Connetion()
{
string path = HttpContext.Current.Server.MapPath("~/App_Data/pizza.mdb"); OleDbConnection connection = new OleDbConnection(@"PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=" + path);
return connection; }
加个N''试试
string strInsert = string.Format("insert into post (
postid,postname,post_address,sex,country,title,mobile,email,state,postmethod,IsMem,describe )
values
('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}')",drop1.SelectedItem.Value.ToString () + "-" + TextBox1.Text.ToString(),
TextBox2.Text + Request.Form["nameE"],
Request.Form["post_address"] + Request.Form["txtpost_address"],
Request.Form["sex"],
Request.Form["country"],
Request.Form["title"],
TextBox4.Text,
TextBox3.Text,
Request.Form["effect1"] + Request.Form["effect2"] + Request.Form["record"], Request.Form["post"] + Request.Form["post1"],
Request.Form["IsNum"],
Request.Form["describe"]);这是我要操作的sql语句 获取页面的值是没有问题的 就是在vs中老报 insert into 语句语法错误
你把 这个sql调试时 放在access 中去执行是可以的 我现在想知道哪里出现了错误 是字段名中有access关键字吗?