vb.net中如何使用#代替数字来查询access数据库中的数据?
在access的数据库中有这样一系列数据BC,BC1,BC2,BC3,K,J,QD等等,我想要在vb。net的程序中显示出所有包含BC字符串的数据,也就是显示BC,BC1...
在access的数据库中有这样一系列数据BC,BC1,BC2,BC3,K,J,QD等等,我想要在vb。net的程序中显示出所有包含BC字符串的数据,也就是显示BC,BC1,BC2这些数据,在access中我用sql建立查询
SELECT asf.Numero_interne_de_la_source_origine from ActiviteSourceFille asf where asf.Numero_interne_de_la_source_origine like 'BC#' or asf.Numero_interne_de_la_source_origine like 'BC' ; 得到了想要的结果,所以在vb.net中
Dim nomSM as String= "BC"
Dim myconnection4 = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data source=" & Application.StartupPath & "\BDDradioactivite.accdb")
Dim mycommand4 As OleDbCommand = myconnection4.CreateCommand()
mycommand4.CommandText =
"SELECT asf.Numero_interne_de_la_source_origine from ActiviteSourceFille asf where asf.Numero_interne_de_la_source_origine like" & "'" & nomSM & "#" & "'"
myconnection4.Open()
Dim myreader4 As OleDbDataReader = mycommand4.ExecuteReader()
myreader4.Read()
MsgBox(myreader4.Item(0).ToString)
myreader4.Close()
myconnection4.Close()
.却总是报错没有任何结果,希望有大神能帮我看看原因,先谢过了 展开
SELECT asf.Numero_interne_de_la_source_origine from ActiviteSourceFille asf where asf.Numero_interne_de_la_source_origine like 'BC#' or asf.Numero_interne_de_la_source_origine like 'BC' ; 得到了想要的结果,所以在vb.net中
Dim nomSM as String= "BC"
Dim myconnection4 = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data source=" & Application.StartupPath & "\BDDradioactivite.accdb")
Dim mycommand4 As OleDbCommand = myconnection4.CreateCommand()
mycommand4.CommandText =
"SELECT asf.Numero_interne_de_la_source_origine from ActiviteSourceFille asf where asf.Numero_interne_de_la_source_origine like" & "'" & nomSM & "#" & "'"
myconnection4.Open()
Dim myreader4 As OleDbDataReader = mycommand4.ExecuteReader()
myreader4.Read()
MsgBox(myreader4.Item(0).ToString)
myreader4.Close()
myconnection4.Close()
.却总是报错没有任何结果,希望有大神能帮我看看原因,先谢过了 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询