这又是怎么回事呢?

csclove 2002-11-26 12:53:11
<%@ import namespace="system.data"%>
<%@import namespace="system.data.oledb"%>
<%@page language="vb" debug="true"%>
<script runat="server">
public newsid as string
public ds as dataset=new dataset
dim dr as datarow
dim conn as oledbconnection
Sub Page_Load(Src As Object, E As EventArgs)
newsid = Request.Params("id")
conn=new oledbconnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source="&server.mappath("../_Database\database.mdb"))
conn.open()
dim mycommand as oledbDataAdapter
mycommand=new oledbDataAdapter("select * from News where id "+newsid,conn)
mycommand.fill(ds,"News")
dr = ds.Tables("News").Rows(0)
Title.Text=dr("Title").ToString()
Content.Text=dr("Content").ToString()
end sub

Sub submit_Click(sender As Object,e As EventArgs)
dim mycommand as OLEDBcommand
dim conn as OLEDBconnection
dim TitleStr as string=Title.Text
dim ContentStr as string=Content.Text
conn=new OLEDBconnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source="&server.mappath("../_Database\database.mdb"))
Conn.open()
mycommand=new OLEDBcommand("UPDATE News set Title='" + TitleStr + "', Content='" + ContentStr + "',DateTime='" + Now.tostring() +"' WHERE id="+newsid,conn)
myCommand.ExecuteNonQuery()
Label1.Text="修改成功!"
End Sub

</script>


在这条语句中mycommand.fill(ds,"News")提示:语法错误 (操作符丢失) 在查询表达式 'id N' 中。
大家帮我看一下这是什么原因哟?
我真的好菜的,但还想学好这东东。
...全文
44 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
xumahua 2002-11-26
  • 打赏
  • 举报
回复
mycommand=new OLEDBcommand("UPDATE News set Title=" & _
"'"& TitleStr &"', Content='"& ContentStr &"',DateTime=" & _
"'"& Now.tostring() &"' WHERE id=newsid",conn)
这样写试试
Lancer903 2002-11-26
  • 打赏
  • 举报
回复
"select * from News where id "+newsid
语句中是不是少了一个“=”号呀?而且看看你传进来的newsid对不对是不是int类型的?如果不是select语句中要加单引号的!

16,555

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧