WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

ADO DAO
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

ADO SQLOLEDB Example


Keywords: SQLOLEDB.1

Question:

I've never done anything like this before, but figured I'd take a stab at it.
Given the following information:
Provider=sqloledb
Network=dbmssocn
data source = datasourcename, 2222
initial catalog=packaging
userid=
pw=
I'd like to query this database for a piece of information from multiple tables. Hope I'm saying that right.

Basically, the db holds the name of packages. Each package has a status. I'd like to query the status of each package. Is there a way to do this with the info I've provided, or am I barking up the wrong tree?

Answer:

It might look something like the following. You can of course step through each row. I just used GetString() for simplicity.
mySQLConn = CreateObject('ADODB.Connection')
mySQLRS = CreateObject('ADODB.Recordset')
mySQLRS.CursorLocation = 3
mySQLConn.Provider = "SQLOLEDB.1"
mySQLConn.ConnectionString = "Provider=SQLOLEDB.1; Network Library=dbmssocn;Password=YOURPWD;User ID=YOURID;Initial Catalog=YOURCATALOG;Data Source=YOURSERVER;"
;mySQLConn.ConnectionString = "Provider=SQLOLEDB.1; Data Source=[servername]; Initial Catalog=[database]; Integrated Security=SSPI;" ;Windows authentication instead of a username password
 
mySQLConn.Open()


SQLText = StrCat(" Select whatever from whatever where whatever ")
mySQLRS.Open (SQLText, mySQLConn, adOpenStatic, adLockReadOnly, adCmdText)
If mySQLRS.EOF == @FALSE Then
   package = mySQLRS.GetString()
   Message("HELLO", package)
EndIf
mySQLRS.Close
mySQLConn.Close()
mySQLRS = 0
mySQLConn = 0 


Article ID:   W17105
File Created: 2012:11:06:10:31:44
Last Updated: 2012:11:06:10:31:44