本文介绍了组合框添加项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
谢谢您的回答.是的,这是我的错误,但是在将字段名称更改为项目名称"之后才是确切的字段名称.现在,它在 dr = cmd.ExecuteReader()行显示语法错误.
请帮帮我!!!
Thank you for answer. Yes, it was my mistake but after changing field name to exact field name as "item Name". Now, it displays syntax error at line dr = cmd.ExecuteReader().
Please help me!!!
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\panchani\Documents\Visual Studio 2005\Transport.mdb")
cmbName.Items.Clear()
cmd.Connection = cn
cmd.CommandText = "select Item Name from item_master"
cn.Open()
dr = cmd.ExecuteReader()
cmbName.Items.Clear()
While (dr.Read)
cmbName.Items.Add(dr("Item Name"))
End While
dr.Close()
推荐答案
cmd.CommandText = "select [Item Name] from item_master"
如果的列名包含空格,则应将其放在方括号中,即[Item Name].
http://dotnetforbeginner.blogspot.com/ [ ^ ]
If the columnname of contains a space then it should be in square brackets i.e., [Item Name].
http://dotnetforbeginner.blogspot.com/[^]
Dim cn As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\panchani\Documents\Visual Studio 2005\Transport.mdb")
Dim cmd As OleDbCommand = New OleDbCommand
cmd.Connection = cn
cmd.CommandText = "select [Item Name] from item_master"
cn.Open()
Dim dr As OleDbDataReader = cmd.ExecuteReader()
cmbName.Items.Clear()
While (dr.Read)
cmbName.Items.Add(dr("Item Name"))
End While
dr.Close()
这篇关于组合框添加项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!