一个名为"temp"的库,含"输入""药品"两个表,"输入"表里有"声母""汉字"两个字段,,"药品"表里有"名称""价格"两个字段,窗体上有data1,adodc1,text1,command1,datagrid1,
command1.caption=A,我想设计成点击command1,text1输出所有声母为A的汉字,然后再到“药品”表里找名称的第一个字等于text1里任意一个字的记录。比如text1输出了
“阿氨”,那么datagrid1能列出
名称 价格
阿莫仙胶囊
阿莫西林胶囊
阿莫西林克拉维酸钾针
氨苄青霉素/丙磺酸(艾罗迪)
氨苄青霉素/丙磺酸(0.25g*12s)
以下是我写的代码:
Private Sub Command1_Click()
Dim str1 As String, str2 As String, x As String, y As String
x = Command1.Caption
str1 = "select 汉字 from 输入 where 字母 like '*" & x & "*'"
Data1.DatabaseName = "D:\Program Files\VB98\database\temp.mdb"
Data1.RecordSource = str1
Data1.Refresh
Text1 = Data1.Recordset.Fields("汉字")
y = Text1.Text
str2 = "select * from 药品 where 名称 like '*" & [y]* & "*'"
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=D:\Program Files\VB98\database\temp.mdb"
Adodc1.RecordSource = str2
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1End Sub
运行时这句 str2 = "select * from 药品 where 名称 like '*" & [y]* & "*'"
出错,而且老是提示“没有指定记录源”
command1.caption=A,我想设计成点击command1,text1输出所有声母为A的汉字,然后再到“药品”表里找名称的第一个字等于text1里任意一个字的记录。比如text1输出了
“阿氨”,那么datagrid1能列出
名称 价格
阿莫仙胶囊
阿莫西林胶囊
阿莫西林克拉维酸钾针
氨苄青霉素/丙磺酸(艾罗迪)
氨苄青霉素/丙磺酸(0.25g*12s)
以下是我写的代码:
Private Sub Command1_Click()
Dim str1 As String, str2 As String, x As String, y As String
x = Command1.Caption
str1 = "select 汉字 from 输入 where 字母 like '*" & x & "*'"
Data1.DatabaseName = "D:\Program Files\VB98\database\temp.mdb"
Data1.RecordSource = str1
Data1.Refresh
Text1 = Data1.Recordset.Fields("汉字")
y = Text1.Text
str2 = "select * from 药品 where 名称 like '*" & [y]* & "*'"
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=D:\Program Files\VB98\database\temp.mdb"
Adodc1.RecordSource = str2
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1End Sub
运行时这句 str2 = "select * from 药品 where 名称 like '*" & [y]* & "*'"
出错,而且老是提示“没有指定记录源”
解决方案 »
- VC++的Dll接口函数转换为VB用
- 请有能力的朋友做一个小程序,有偿.
- 兴趣题.超难度
- 如何将数据写入程序自身,请求多种方法。
- 如果一台电脑是直接连入因特网的,而另一台电 脑为于一个局域网内,那种简单的聊天程序是否能成功通信
- 如何将A数据库中的一张表复制到B数据库中?!两个数据库都有密码!
- 为什么自定义的消息用PostThreadMessage发送后不能被我的窗口函数拦截呢?
- vb for excel问题!
- 编一个小程序真麻烦,但终于只剩下最后一个打包的问题
- ???关于on error goto的问题???
- 我写好了一个程序,想要它只运行在服务中,在界面上看不到????
- 实在没办法了,各位高手帮帮在下吧!
这样写:str2 = "select * from 药品 where 名称 like '*[" & y & "]*'"
"select a.*,b.* from a, b where a.名称 = b.名称 and a.字母='a'"