Dim sql As String
Dim str As String
Dim conn As New Connection
Dim rst As New ADODB.Recordset
Dim tmpno As String
Dim tmpchar As StringWith quotationno
tmpno = .Getno
End Withtmpchar = Left(tmpno, 9)sql = "select * from quotation where refno like "
str = "DRIVER={SQL Server};SERVER=leon;UID=sa;PWD=800728;DATABASE=material"sql = "select * from quotation where refno like "要like tmpchar
怎么写,我写了好几个是错的
Dim str As String
Dim conn As New Connection
Dim rst As New ADODB.Recordset
Dim tmpno As String
Dim tmpchar As StringWith quotationno
tmpno = .Getno
End Withtmpchar = Left(tmpno, 9)sql = "select * from quotation where refno like "
str = "DRIVER={SQL Server};SERVER=leon;UID=sa;PWD=800728;DATABASE=material"sql = "select * from quotation where refno like "要like tmpchar
怎么写,我写了好几个是错的
这样可以。
实时错误'-2147217900 (8004e14)'
[microsoft][odbc sql server driver][sql server]列名
'Q20041019'无效。
sql = "select * from quotation"
就没问题
str = "DRIVER={SQL Server};SERVER=leon;UID=sa;PWD=800728;DATABASE=material"
conn.Open str
rst.Open sql, connIf rst.EOF = True Then
txtquotationno = tmpchar & "001"
Else
txtquotationno = "111"
End Ifrst.Close
conn.Close运行出来的结果不对吧
我数据库quotation中的refno有Q20041019002这个数据,但是没有找到
select * from quotation where id like '%fdsa%' '内容需要用单引号引上
在VB里就要写成
str= "select * from quotation where id like" & "'%" & str1 & "%'" '需要把这个单引号和%用双引号引起来. str1是一个变量你要查询的内容是什么啊??你后面想like 什么啊??
比如id like 1
就要等于1
tmpchar =1
语句执行没问题,那就说明语句没错,结果不是你想要的,那说明你的tmpchar的值没有设置好!!
你在加上%按这个帖子上面的语句试试!
& "'" & tmpchar & "%'"