db connection

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
brentmtc
Newbie
Posts: 8
Joined: Wed Jun 04, 2008 7:20 pm
Location: U.S.

db connection

Post by brentmtc » Wed Jun 04, 2008 9:39 pm

Trying to make a db connection (SQL Server 2000) and then populate a table (by executing a stored procedure) with data. I keep receiving an assortment of errors. Any suggestions to fix my code would be appreciated.

// Create db connection, insert values into generic table, and close db connection
VBSTART
Dim connstr
Dim MyDB
Dim rs

connstr= "Driver={OBDC MS SQL Server}; Data Source=***-***-***-*;Initial Catalog=db**;Persist Security Info=True;User ID=***;Password=****;"


Set MyDB = CreateObject("ADODB.Connection")
MyDB.Open connstr


rs = MyDB.Execute("uspScreenScrape_Test;")


VBEND

Thank you. :)

-brentmtc

edauthier
Pro Scripter
Posts: 84
Joined: Sun Apr 13, 2003 1:26 pm
Location: USA

Post by edauthier » Thu Jun 05, 2008 2:42 am

Is your code missing> VBRUN>?

I use DBCONNECT> when using Macro Scheduler:
Like so:
Let>connstr=Driver={SQL Native Client};Server=servername\sqlinstance; Database=SQL; Uid=user; Pwd=password;

DBConnect>connstr,dbH

User avatar
Marcus Tettmar
Site Admin
Posts: 7391
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Jun 05, 2008 6:03 am

"assortment of errors"? Please try being a little more specific.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

brentmtc
Newbie
Posts: 8
Joined: Wed Jun 04, 2008 7:20 pm
Location: U.S.

db Connection

Post by brentmtc » Thu Jun 05, 2008 3:57 pm

I am now getting a connection to the db and able to insert some hard coded values(as in the commented out Let>) but I am not able to get values from the 'screen scrape' to be inserted using a stored procedure. Here is the code I have now.

Let>str=Driver={SQL SERVER};Server=***;Port=****;Database=***;User=***;Password=****;
DBConnect>str,dbH

//Let>SQL=Insert into tbGeneric_Patient_Info(LastName, FirstName) Select 'Harris', 'Sean'
Let>SQL=("uspScreenScrape_Test";)
DBExec>dbH,SQL,result

DBClose>dbH

Some of my 'screen scrape' values are %MRN%, %Suffix%,
%LastName%, etc.

Have any suggestions?

Thank you :)

-brentmtc

edauthier
Pro Scripter
Posts: 84
Joined: Sun Apr 13, 2003 1:26 pm
Location: USA

Post by edauthier » Tue Jun 10, 2008 9:48 pm

Brent
I currently do not use MS for sprocs, but maybe I can assist you. Did you have any luck with this?

Ed

brentmtc
Newbie
Posts: 8
Joined: Wed Jun 04, 2008 7:20 pm
Location: U.S.

db connection

Post by brentmtc » Wed Jun 11, 2008 1:18 pm

I have not got my macro to execute my stored procedures yet. Any suggestions?










Thanks,

-brentmtc

edauthier
Pro Scripter
Posts: 84
Joined: Sun Apr 13, 2003 1:26 pm
Location: USA

Post by edauthier » Thu Jun 12, 2008 3:36 am

adCmdStoredProc=4
cmd.CommandText = "uspScreenScrape_Test"
cmd.commandtype=adCmdStoredProc

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts