怎么进行查询名字啊

x98188 2003-12-12 05:31:49
Private Sub Command1_Click()
Set rs = New ADODB.Recordset
SQL = "select * from students where studentid='" & textsea.Text & "'"
rs.CursorLocation = adUseClient
rs.Open SQL, conn, adOpenDynamic, adLockOptimistic
Set DataGrid1.DataSource = rs
End Sub
提示'liwen'附近有语法错误
liwen就数据库里面的一个名字


...全文
114 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
SoHo_Andy 2003-12-12
  • 打赏
  • 举报
回复
DataGrid1.refresh
这个语句只是使查询的记录集绑定之后的刷新动作,应该和你的错误没有直接
关系的

至于为什么可以了,说实话我也不清楚
x98188 2003-12-12
  • 打赏
  • 举报
回复
SoHo_Andy(冰) 可以拉,
只是加了个DataGrid1.refresh
请问为什么啊
yoki 2003-12-12
  • 打赏
  • 举报
回复
SQL = "select * from students where studentname='" & textsea.Text & "'"
yoki 2003-12-12
  • 打赏
  • 举报
回复
SQL = "select * from students where 名字='" & textsea.Text & "'"
SoHo_Andy 2003-12-12
  • 打赏
  • 举报
回复
注意如果studentid是数字类型的
SQL = "select * from students where studentid=" & textsea.Text & ""
如果studentid是字符类型的
SQL = "select * from students where studentid='" & textsea.Text & "'"

你的语法没有任何问题
Private Sub Command1_Click()
Set rs = New ADODB.Recordset
SQL = "select * from students where studentid='" & textsea.Text & "'"
rs.CursorLocation = adUseClient
rs.Open SQL, conn, adOpenDynamic, adLockOptimistic
Set DataGrid1.DataSource = rs
DataGrid1.refresh
End Sub

1,217

社区成员

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

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