×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

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

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

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

(OP)
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?

http://support.crystaldecisions.net/library/kbase/articles/c2006666.asp

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!
http://www.smsforce.com
http://www.goodguyz.com

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

(OP)
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=SQEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Collections;Data Source=" & SystemUsed
    crxrpt.Database.AddOLEDBSource connectionstr, "TABLENAME"


Brett

Please visit my websites!
http://www.smsforce.com
http://www.goodguyz.com

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

(OP)
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!
http://www.smsforce.com
http://www.goodguyz.com

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

I am facing a problem when i am trying to open a report i am getting a error that server is not open.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close