vb.net连接access System.Data.OleDb.OleDbException 5

EndIfDimidAsInt16=0DimlbAsString=""DimpageAsInt16=0id=Request.QueryString("id")lb=Req... End If
Dim id As Int16 = 0
Dim lb As String = ""
Dim page As Int16 = 0
id = Request.QueryString("id")
lb = Request.QueryString("lb")
page = Request.QueryString("page")
Dim myConn As Data.OleDb.OleDbConnection = New Data.OleDb.OleDbConnection
Dim strinst As String
Dim inst As Data.OleDb.OleDbCommand
myConn.ConnectionString = Application("connstr")
myConn.Open()
If id <> 0 Then
strinst = ""
strinst &= "update 新闻 set "
strinst &= "标题='" & Trim(TextBox2.Text) & "',"
strinst &= "内容='" & FreeTextBox1.Text & "',"
strinst &= "作者='" & Trim(TextBox1.Text) & "',"
If Not File1.PostedFile Is Nothing And File1.PostedFile.FileName <> "" Then
strinst &= "图片数=1,"
Else
strinst &= "图片数=0,"
End If
strinst &= "类别='" & DropDownList1.SelectedItem.Text & "'"
strinst &= " where id=" & id
Else
strinst = ""
strinst &= "insert into 新闻(标题,内容,作者,类别,发布日期,发布人,图片数,次数)values("
strinst &= "'" & Trim(TextBox2.Text) & "',"
strinst &= "'" & FreeTextBox1.Text & "',"
strinst &= "'" & Trim(TextBox1.Text) & "',"
strinst &= "'" & DropDownList1.SelectedItem.Text & "',"
strinst &= "'" & Today & "',"
strinst &= "'" & Session("name") & "',"
If Not File1.PostedFile Is Nothing And File1.PostedFile.FileName <> "" Then
strinst &= "1,"
Else
strinst &= "0,"
End If
strinst &= "1"
strinst &= ")"
End If
inst = New Data.OleDb.OleDbCommand(strinst, myConn)
inst.ExecuteNonQuery()
展开
 我来答
若以下回答无法解决问题,邀请你更新回答
syx54
2015-03-09 · TA获得超过7378个赞
知道大有可为答主
回答量:6567
采纳率:83%
帮助的人:2738万
展开全部
数据库连接的几个步骤:
Dim myConn As OleDbConnection = New OleDbConnection '声明并实例化数据库连接对象
'数据库连接字符串(注意:这里假设数据库文件保存在D盘根目录中)
Dim myConnection As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\数据库实例.mdb "
myConn.ConnectionString = myConnection '设置数据库连接对象的数据库连接字符串属性
myConn.Open() '打开数据库连接
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式