这段代码有问题没?还是数据库的有问题,运行提示的是Insert 语句有错误,用户代码未处理OleDBException
DimstrConAsString="Provider=Microsoft.Jet.OLEDB.4.0;DataSource="&Server.MapPath("../d...
Dim strCon As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("../data/data.mdb")
conn.ConnectionString = strCon
conn.Open()
Dim cmd As New OleDbCommand
'Try
Dim strSql As String = "insert into image( [newsimage] ) values('" & Trim(newstitle.Text) & "')"
cmd.CommandText = strSql
cmd.Connection = conn
Dim rs As OleDbDataReader
rs = cmd.ExecuteReader
conn.Close() 展开
conn.ConnectionString = strCon
conn.Open()
Dim cmd As New OleDbCommand
'Try
Dim strSql As String = "insert into image( [newsimage] ) values('" & Trim(newstitle.Text) & "')"
cmd.CommandText = strSql
cmd.Connection = conn
Dim rs As OleDbDataReader
rs = cmd.ExecuteReader
conn.Close() 展开
3个回答
展开全部
Dim strSql As String = "insert into image( [newsimage] ) values('" & Trim(newstitle.Text) & "')"
好像错了,[newsimage]这是字段名还是表名?要表明在前面,要是字段字的话,把中括号去掉看一下!
好像错了,[newsimage]这是字段名还是表名?要表明在前面,要是字段字的话,把中括号去掉看一下!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
('" & Trim(newstitle.Text) & "')
加上‘’?
加上‘’?
追问
在哪里加?
追答
你拼接的时候出错了
insert into image( [newsimage] ) values(Trim(‘“+newstitle.Text+”‘) )
这样才行吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询