Article ID: 151161
Article Last Modified on 6/24/2004
sql2 = " select * from TestTable where Field2 = 'A001'" Set rs2 = cn.OpenResultset(sql2)
CREATE TABLE dbo.TestTable (
Field1 int IDENTITY (1,1)NOT NULL,
Field2 varchar (10))
use "INSERT INTO TestTable ( Field2 ) VALUES ('A001')" to add a record.
Private Sub Command1_Click()
Dim cn As rdoConnection
Dim en As rdoEnvironment
Dim rs1 As rdoResultset, rs2 As rdoResultset
Dim cnstr As String, sql1 As String, sql2 As String
Set en = rdoEnvironments(0)
cnstr = "driver={sql server};server=jingsun;Username=<username>;PWD=<strong password>;database=pubs"
Set cn = en.OpenConnection(dsname:="", _
Prompt:=rdnoprompt, _
ReadOnly:=False, _
Connect:=cnstr)
sql1 = "select * from TestTable where Field2 = 'a001'"
sql2 = "select * from TestTable where Field2 = 'A001'"
Set rs1 = cn.OpenResultset(sql1)
Set rs2 = cn.OpenResultset(sql2)
' You expect rs1 to return 0 rows and rs2 to return 1 row.
' However, since the second SQL statement in the OpenResultSet method
' only differs in case from the first one, the second OpenResultSet
' method still sends the first SQL statement to the server and causes
' 0 return rows.
If rs2.EOF Then
MsgBox "No rows returned"
Else
MsgBox rs2(0) & ", " & rs2(1)
End If
MsgBox cn.rdoPreparedStatements.Count
rs1.Close
rs2.Close
cn.Close
End Sub
Additional query words: kbVBp400 kbVBp600 kbdse kbDSupport kbVBp kbRDO
Keywords: kbprb KB151161