导航
  • 全部
...

为什么总是说from子句语法错误?thx

battry 2003-03-10 11:59:58
就是sql语句那里出错,谢谢哪位帮我看看。

Dim cnn As New ADODB.Connection
Dim rs As New ADODB.Recordset
cnn.Open "provider=microsoft.jet.oledb.4.0;" & "data source=.\gz.mdb;"
rs.Open "select username,pwd from user where username=txtusername.text and pwd=txtpassword.text", cnn
If rs.RecordCount > 0 Then
...全文
给本帖投票
107 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
battry 2003-03-11
  • 打赏
  • 举报
回复
而且我之前想用data控件连接数据库gz.mdb,提示说是不可识别的数据库格式
哪位帮帮我,会不会是vb设置方面的问题
battry 2003-03-11
  • 打赏
  • 举报
回复
提示说编译错误,缺少:语句结束("' and pwd='")
battry 2003-03-11
  • 打赏
  • 举报
回复

这样它就说语法错误,子句没有结束
rs.Open "select count(*) from user where username='"&txtusername.text&"' and pwd='"&txtpassword.text&"'", cnn
jin11 2003-03-11
  • 打赏
  • 举报
回复
rs.Open "select username,pwd from user where username='" & txtusername.text & "' and pwd='" & txtpassword.text & "'", cnn
northwolves 2003-03-11
  • 打赏
  • 举报
回复
rs.Open "select username,pwd from user where username='" & Trim(txtusername.Text) & "' and pwd='" & Trim(txtpassword.Text) & "'", cnn
if not rs.eof then
饮水需思源 2003-03-11
  • 打赏
  • 举报
回复
select username,pwd from [user] where username='" & txtusername.text &"' and pwd='" & txtpassword.text &"'"

两处不对:
  1,表名user为SQL的关键字,要用[]括起来,最好不要用SQL的关键字作为表名与字段名
2,字符变量在语句中要用 '"& 变量名 &"'

1,217

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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

手机看
关注公众号

关注公众号

客服 返回
顶部