Dim mySQL As String
Dim my As String
Dim tt As String
Set rs = New ADODB.Recordset
tt = "192.168.1.101"
mySQL = "select 暱稱 from 聊天明細 where IP like 'tt' "
rs.Open mySQL, cn, adOpenStatic, adLockOptimistic
my = rs.GetString
Text2.Text = my
我想給變數,還後從access裡抓回我要東西,這段where IP like 'tt'的tt是無效,要怎麼寫才能抓回我要的資料,而且抓回後放在變數中
Dim my As String
Dim tt As String
Set rs = New ADODB.Recordset
tt = "192.168.1.101"
mySQL = "select 暱稱 from 聊天明細 where IP like 'tt' "
rs.Open mySQL, cn, adOpenStatic, adLockOptimistic
my = rs.GetString
Text2.Text = my
我想給變數,還後從access裡抓回我要東西,這段where IP like 'tt'的tt是無效,要怎麼寫才能抓回我要的資料,而且抓回後放在變數中
文章標籤
全站熱搜

:::你這樣是要找IP裡面是tt的字串哩,正確應該是: mySQL = "select 暱稱 from 聊天明細 where IP like '" & tt & "'"
mySQL = "select 暱稱 from 聊天明細 where IP = '" & tt & "'" 其實這樣會好一點,因為他的 IP 沒有萬用字元,應該是找指定 IP
感謝小琳和紀文和你們的方法我都試過了,都ok,謝謝