| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 541 人关注过本帖
标题:使用insert intio语句出现语法错误,请指点
只看楼主 加入收藏
airfei
Rank: 1
等 级:新手上路
帖 子:137
专家分:0
注 册:2007-4-12
收藏
 问题点数:0 回复次数:4 
使用insert intio语句出现语法错误,请指点

在插入数据的时候提示insert into 语法错误,帮我看看错在哪里,我使用的是Access数据库,谢谢

protected void btn_submit_Click(object sender, EventArgs e)
{
string CnnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("lmyfback.mdb");
OleDbConnection con = new OleDbConnection(CnnString);
con.Open();

string sex = "0";
string jiameng = "0";
string net = "0";
string paper = "0";
string friend = "0";
string qita1 = "0";
string shop = "0";
string select = "0";
string market = "0";
string tese = "0";
string pin = "0";
string tixi = "0";
string qita2 = "0";
string fx = "0";
string fy = "0";
string tj = "0";
string noneTS = "0";
string qj = "0";
string yx = "0";
string qita3 = "0";

if(this.rbtn_man.Checked)
{
sex = "男";
}
if(this.rbtn_woman.Checked)
{
sex = "女";
}

if(this.ckb_jm.Checked)
{
jiameng = "1";
}
if(this.ckb_net.Checked)
{
net = "1";
}
if(this.ckb_paper.Checked)
{
paper = "1";
}
if (this.ckb_friend.Checked)
{
friend = "1";
}
if (this.ckb_qita1.Checked)
{
qita1 = "1";
}
if(this.rbtn_yes.Checked)
{
shop = "1";
}
if(this.rbtn_none.Checked)
{
shop = "0";
}
if(this.rbtn_shi.Checked)
{
select = "1";
}
if(this.rbtn_fou.Checked)
{
select = "2";
}
if(this.rbtn_kl.Checked)
{
select = "3";
}
if(this.ckb_market.Checked)
{
market = "1";
}
if(this.ckb_tese.Checked)
{
tese = "1";
}
if(this.ckb_pin.Checked)
{
pin = "1";
}
if(this.ckb_tixi.Checked)
{
tixi = "1";
}
if(this.ckb_qita2.Checked)
{
qita2 = "1";
}
if(this.ckb_fx.Checked)
{
fx = "1";
}
if(this.ckb_fy.Checked)
{
fy = "1";
}
if(this.ckb_tj.Checked)
{
tj = "1";
}
if(this.ckb_noneTS.Checked)
{
noneTS = "1";
}
if(this.ckb_qj.Checked)
{
qj = "1";
}
if(this.ckb_yx.Checked)
{
yx = "1";
}
if(this.ckb_qita3.Checked)
{
qita3 = "1";
}


OleDbCommand cmd = new OleDbCommand("insert into lmyfback([name],[sex],[job],[jiguan],[tel],[email],[jiameng],[net],[paper],[friend],[qita1],[invest],[area],[shop],[mj],[impress],[select],[market],[tese],[pin],[tixi],[qita2],[fx],[fy],[tj],[noneTS],[qj],[yx],[qita3],[yj]) values('" + this.tbx_name.Text.Trim() + "','" + sex + "','" + this.tbx_job.Text.Trim() + "','" + this.tbx_jiguan.Text.Trim() + "','" + this.tbx_tel.Text.Trim() + "','" + this.tbx_email.Text.Trim() + "','" + jiameng + "','" + net + "','" + paper + "','" + friend + "','" + qita1 + "','" + this.tbx_invest.Text.Trim() + "','" + this.tbx_area.Text.Trim() + "','" + shop + "','" + this.tbx_mj.Text.Trim() + "','" + this.tbx_impress.Text.Trim() + "','" + select + "','" + market + "','" + tese + "','" + pin + "','" + tixi + "','" + qita2 + "','" + fx + "','" + fy + "','" + tj + "','" + noneTS + "','" + qj +"','" + yx + "','" + qita3 + "','" + this.tbx_yj.Text.Trim() + "'", con);
try
{
cmd.ExecuteNonQuery();
Response.Write("<script>window.alert('加盟申请提交成功,谢谢您的支持!');</script>");
}
catch (Exception ex)
{
Response.Write(ex.Message);
//Response.Write("<script>window.alert('加盟申请提交失败,请稍后再试...');</script>");
}
finally
{
con.Close();
}
}

搜索更多相关主题的帖子: insert intio 语法 语句 
2007-08-31 13:24
bygg
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:乖乖的心中
等 级:版主
威 望:241
帖 子:13555
专家分:3076
注 册:2006-10-23
收藏
得分:0 

错误信息是什么啊?
或者你设置个断点,把语句放到SQL查询分析器中去检查一下语法吧


飘过~~
2007-08-31 14:30
airfei
Rank: 1
等 级:新手上路
帖 子:137
专家分:0
注 册:2007-4-12
收藏
得分:0 

错误是insert into语法错误

2007-08-31 16:46
bygg
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:乖乖的心中
等 级:版主
威 望:241
帖 子:13555
专家分:3076
注 册:2006-10-23
收藏
得分:0 
太多了,看到眼睛很花啊,你设个断点看看嘛

飘过~~
2007-08-31 16:59
梦灵儿
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:260
专家分:9
注 册:2007-8-7
收藏
得分:0 
有点不懂楼主的意思为什么要给字符串变量赋初?
还有建议不要把SQL语句写在命令对象里。这样看错不好找。建议使用一个字符串然后设置一个断点看看哪个值没有取出来或则语法有错误。

2007-08-31 18:30
快速回复:使用insert intio语句出现语法错误,请指点
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012097 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved