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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need to know how to change the dsn for odbc thru vb6 code

Status
Not open for further replies.

bburnell

Programmer
Joined
Sep 15, 2000
Messages
560
Location
US
Hi,
The project I am working on uses ODBC sources from our "test" and "production" SQL Server 7 servers. I have added a parameter to the exe file that if you add "TEST" it will pull from the test system using SQL commands hard coded in VB6. I need to know how in VB6 (SP4) and/or CR v8.0441 code how to do this "on the fly." I have tried the LogOnServer command with no success. I don't understand the "SetLogOnInfo" command at all. I have stored procedures and data on the different servers I need to point to. I use about 20 rpt files thru 1 CR viewer form and that is my biggest problem with using the examples that I have found on this forum and in Crystal Decisions website/knowledge base.

I am using this code:
Dim crxapp As New CRAXDRT.Application
Dim crxrpt As New CRAXDRT.Report
Dim frmViewerForm As frmRPT2Viewer

Set frmViewerForm = New FrmRPT2Viewer

if WhichSystem = "TEST" then
crxapp.LogOnServer "p2sodbc.dll", "testdb", "Collections", "userid", "password"
else
crxapp.LogOnServer "p2sodbc.dll", "proddb", "Collections", "userid", "password"
endif

Set crxrpt = crxApp.OpenReport("C:\Report09")
frmViewerForm.CRViewer1.ReportSource = crxrpt
frmViewerForm.CRViewer1.ViewReport
frmViewerForm.Show




Here is the EXACT error I get now and the fix(?) Which "solution" do I use in my case?


Here is what I'm using:
crxApp.LogOnServer "p2sodbc.dll", systemname, "Collections", "", ""

- systemname is a variable set based on parameter passed ("S6" for test) ("DELL6300" for prod)
- "Collections" is the table name of the SQL Server (according to M$ Intellisense)
- I want the userid and password of Win NT login passed.

Any ideas on this one?
Thanks,
Brett Please visit my websites!
 
I got it to work!

'*** CHANGE THE ODBC/OLE DB DSN ON THE FLY! ***
'*** SystemUsed is either "test" [S6] or "prod" (DELL6300] ***

dim ConnectionStr as string
ConnectionStr = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Collections;Data Source=" & SystemUsed
crxrpt.Database.AddOLEDBSource connectionstr, "TABLENAME"


Brett Please visit my websites!
 
Stupid Emoticons!

I got it to work!

'*** CHANGE THE ODBC/OLE DB DSN ON THE FLY! ***
'*** SystemUsed is either "test" [S6] or "prod" [DELL6300] ***

dim ConnectionStr as string
ConnectionStr = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Collections;Data Source=" & SystemUsed
crxrpt.Database.AddOLEDBSource connectionstr, "TABLENAME"


Brett Please visit my websites!
 
I am facing a problem when i am trying to open a report i am getting a error that server is not open.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top