|
-
April 11th, 2001, 10:42 PM
#1
System Dsn (Crystal Report)
Is there a way using which I can create system DSN from VB . I do not want the user of my application to create it.I know there is another way to do is by creating file DSN but in my situation i can not use file DSN basically I am using crystal reports 7.0 and to connect to database i want to use dsn.
So there are actualy two questions :
1) How can I create system DSN from vb?
2) How can I use file DSN in crystal Reports 7.0 ?
-
April 12th, 2001, 02:06 AM
#2
Re: System Dsn (Crystal Report)
The great Lothar once answered this:
'--------
I don't know much about the RegisterDatabase call.
Fact is, the SQLConfigDataSource API supports creation of system DSNs.
sample:
Declare Function SQLConfigDataSource Lib "ODBCCP32.dll" ( _ byval h as Long, byval r as Long, byval strDriver as string, _ byval strattr as string) as Long
Declare Function SQLInstallerError Lib "ODBCCP32.dll" ( _ byval n as Long, byref r as Long, byval strError as string, _ byval lLen as Long, byref thelen as Long) as Long
public Sub cfg()
Dim s as strings = "DSN=LAH" & vbNullChar & "DATABASE=yourdb" & _ vbNullChar
& "SERVER=yourserver" & _ vbNullChar
If SQLConfigDataSource(0, 1, "SQL Server", s) = 0 then
MsgBox "no luck"
Dim r as Long
Dim strError as string
strError = string(255, " ")
Dim lLen as Long
SQLInstallerError 1, r, _
strError, 255, lLen
MsgBox strError
else
MsgBox "ok"
End If
End Sub
'and, in a second time:
how do you add or delete a DSN? SQLConfigDataSource?
its fRequest argument can take one of 3 values:
ODBC_ADD_DSN
ODBC_CONFIG_DSN for editing
ODBC_REMOVE_DSN
try the second one.
Personally, I usually delete and recreate a DSN.
'-----------
Special thanks to Lothar "the Great" Haensler. Come back soon, you Guru.
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
-
April 12th, 2001, 02:09 AM
#3
Re: System Dsn (Crystal Report)
Whoops...
have a look:
http://codeguru.com/cgi-bin/bbs/wt/s...age=&view=&sb=
as Iouri also suggested something great...
Special thanks to Lothar "the Great" Haensler. Come back soon, you Guru.
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|