标题:[求助]爆炸了,cmd.ExecuteNonQuery()问题!
取消只看楼主
wlqing2004
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2007-10-9
 问题点数:0 回复次数:0 
[求助]爆炸了,cmd.ExecuteNonQuery()问题!

Dim Conn As New OleDb.OleDbConnection
Dim connstr As String
Dim ad As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter
connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\vb.mdb"
Dim dt As New DataSet

Dim sql As String
sql = "insert into admin(usename,password) values ('" + Me.TextBox1.Text + "' , '" + Me.TextBox1.Text + "')"
Conn = New OleDb.OleDbConnection(connstr)

Conn.Open()
Dim cmd As New OleDb.OleDbCommand(sql, Conn)
cmd.ExecuteNonQuery()
Conn.Close()
MsgBox("ok!")



这段代码是向数据库插入记录的,如果SQL语句为sql = "insert into admin(usename) values ('" & Me.TextBox1.Text & "' )" (只插入一个列),就能成功,也能插入数据,但是如果想插入两个列,就在
cmd.ExecuteNonQuery() 出说insert into 语法错误,到底是怎么回事,昨天晚上弄到4:00也没搞定,今天起早继续,依然没弄好,

搜索更多相关主题的帖子: cmd 
2007-10-20 12:54



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-179279-1-1.html




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

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