vb的adodc控件的问题
这是我的程序,目的是让access表中的内容在下拉表中显示,但是总是报错说"仓库管理.食品名称不能是零长度的字符串",各位大侠帮个忙把DimiAsIntegerDimsq...
这是我的程序,目的是让access表中的内容在下拉表中显示,但是总是报错说"仓库管理.食品名称不能是零长度的字符串",各位大侠帮个忙把
Dim i As Integer
Dim sq1 As String
Combo1.Clear
Combo2.Clear
Combo3.Clear
Adodc1.RecordSource = "select 食品名称,产地,有效期 from 仓库管理"
Adodc1.Refresh
Adodc1.Recordset.MoveFirst
For i = 0 To Adodc1.Recordset.RecordCount - 1
Combo1.AddItem Adodc1.Recordset.Fields(0).Value
Combo2.AddItem Adodc1.Recordset.Fields(1).Value
Combo3.AddItem Adodc1.Recordset.Fields(2).Value
Adodc1.Recordset.MoveNext
Next
Combo1.ListIndex = 0
Combo2.ListIndex = 0
Combo3.ListIndex = 0
一楼和二楼的大哥的答案都是了,还是同样的错误.不过还是要谢一下.有没有人再帮我看看啊 展开
Dim i As Integer
Dim sq1 As String
Combo1.Clear
Combo2.Clear
Combo3.Clear
Adodc1.RecordSource = "select 食品名称,产地,有效期 from 仓库管理"
Adodc1.Refresh
Adodc1.Recordset.MoveFirst
For i = 0 To Adodc1.Recordset.RecordCount - 1
Combo1.AddItem Adodc1.Recordset.Fields(0).Value
Combo2.AddItem Adodc1.Recordset.Fields(1).Value
Combo3.AddItem Adodc1.Recordset.Fields(2).Value
Adodc1.Recordset.MoveNext
Next
Combo1.ListIndex = 0
Combo2.ListIndex = 0
Combo3.ListIndex = 0
一楼和二楼的大哥的答案都是了,还是同样的错误.不过还是要谢一下.有没有人再帮我看看啊 展开
1个回答
展开全部
从你给的代码看缺一句数据库连接语句.现修改如下,请将第6句的数据库路径和名称改为你的数据库路径和名称:
Dim i As Integer
Dim sq1 As String
Combo1.Clear
Combo2.Clear
Combo3.Clear
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Downloads\VB_program\db1.mdb;Persist Security Info=False"
Adodc1.RecordSource = "select 食品名称,产地,有效期 from 仓库管理"
Adodc1.Refresh
Adodc1.Recordset.MoveFirst
For i = 0 To Adodc1.Recordset.RecordCount - 1
Combo1.AddItem Adodc1.Recordset.Fields(0).Value
Combo2.AddItem Adodc1.Recordset.Fields(1).Value
Combo3.AddItem Adodc1.Recordset.Fields(2).Value '
Adodc1.Recordset.MoveNext
Next
Combo1.ListIndex = 0
Combo2.ListIndex = 0
Combo3.ListIndex = 0
Dim i As Integer
Dim sq1 As String
Combo1.Clear
Combo2.Clear
Combo3.Clear
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Downloads\VB_program\db1.mdb;Persist Security Info=False"
Adodc1.RecordSource = "select 食品名称,产地,有效期 from 仓库管理"
Adodc1.Refresh
Adodc1.Recordset.MoveFirst
For i = 0 To Adodc1.Recordset.RecordCount - 1
Combo1.AddItem Adodc1.Recordset.Fields(0).Value
Combo2.AddItem Adodc1.Recordset.Fields(1).Value
Combo3.AddItem Adodc1.Recordset.Fields(2).Value '
Adodc1.Recordset.MoveNext
Next
Combo1.ListIndex = 0
Combo2.ListIndex = 0
Combo3.ListIndex = 0
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询