str6在for回圈的時候已經得到了德州這兩個字符,但是就是在資料庫讀不到資料(在rs.Read()之后就讀不到了),如果直接把str6="德州"就可以讀到資料。這是為啥?
For i = 2 To 20
str6 = TextBox1.Text.Substring(i, 2)
If str6 <> "" Then
Call OpenConn()
Command1.CommandText = "select distinct province,city from dbo.pcc where city2 =" & "'" & str6 & "'"
Command1.CommandType = CommandType.Text
rs = Command1.ExecuteReader()
If rs IsNot Nothing Then
rs.Read()
If rs.HasRows Then
If ComboBox1.Text = "" Then
ComboBox1.Text = rs.GetString(0)
End If
ComboBox2.Text = rs.GetString(1)
If rs IsNot Nothing Then
Call CloseConn()
End If
Exit For
End If
End If
End If
Next
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/236779.html
標籤:VB基礎類
