Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Recordset

Status
Not open for further replies.

SQLScholar

Programmer
Aug 21, 2002
2,127
GB
Hi all,

Myself and a work mate are trying to get a connection to SQL and to populate the data from an execute into a recordset. Problem is that it doesnt seem to be working. The rs.recordcount is coming back as -1. There is definitely data there, and the SQL connection is fine (tried an insert using execute and it worked!)

Code below:

Code:
	    Dim conn
            Dim rs As New ADODB.Recordset
            Dim command As New ADODB.Command
            Dim objArray
            Dim strSql

            conn = Server.CreateObject("ADODB.Connection")
            conn.open("Driver={SQL Server};Server=xxx;Database=xxx; Uid=xxx;Pwd=xxx;")
            strSql = "SELECT * FROM tableName"
            
            With command
                .CommandText = strSql
                .ActiveConnection = conn
            End With
            
            rs = command.Execute

            Response.Write(rs.RecordCount)

Any ideas?

Dan

----------------------------------------
Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind - Dr. Seuss

Computer Science is no more about computers than astronomy is about telescopes - EW Dijkstra
----------------------------------------
 
these are COM objects. the .net framework uses ADO.Net to communicate with a database. this means either you are coding in asp, or you are not taking advantage of the .net framework and asp.net

if you are coding asp then try forum333. if this is an asp.net project use the ado.net components to connect to the database. the objects can be found in the System.Data... namespace.

better yet (assuming a .net project) use a data access framework which reduces the repetition of connection/command management with one of the follow OSS frameworks
nhibernate
active record
ms data access block

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top