|
-
November 19th, 1999, 09:21 AM
#1
Create DSN with COM object
there is an "ODBC driver & data source names functions" COM component in the references in my VB 6installation.
Has anyone ever used the CreateDSN method of the ODBCTool.DSN object with success?
No matter what I entered, it didn't create a DSN nor did it raise an error.
-
November 19th, 1999, 01:04 PM
#2
Re: Create DSN with COM object
This created a User DSN just Fine for me..
private Sub Command1_Click()
Dim oODBC as new ODBCTool.Dsn
If oODBC.CreateDSN("VB Created User DSN", "SQL Server", "<MySQLServerName>", "<MySQLDBName>", "", "", "Created via VB6.0", true, "") then
MsgBox "DSN Created Successfully"
End If
End Sub
Aaron Young
Analyst Programmer
[email protected]
[email protected]
-
November 22nd, 1999, 02:50 AM
#3
Re: Create DSN with COM object
your code works very well.
Do you know how to change it to create a system DSN?
-
November 22nd, 1999, 02:32 PM
#4
Re: Create DSN with COM object
I haven't been successfull in creating a System DSN with the DAETools.dsn Object, but, I have found an alternative method:
private Declare Function SQLConfigDataSource Lib "odbccp32.dll" (byval hwndParent as Long, byval fRequest as Integer, byval lpszDriver as string, byval lpszAttributes as string) as Long
Const ODBC_ADD_SYS_DSN = 4
private Sub Command1_Click()
If SQLConfigDataSource(0&, ODBC_ADD_SYS_DSN, "SQL Server", "DSN=My System DSN" & Chr(0) & "Server=<MySQLServer>" & Chr(0) & "Database=<MyDB>" & Chr(0) & "UseProcForPrepare=Yes" & Chr(0) & "Description=VB Created System DSN" & Chr(0) & Chr(0)) then
MsgBox "DSN Created"
End If
End Sub
For More Information on how to use this DLL, check here on the MSDN Site: Http://msdn.microsoft.com/library/ps...k/odch3kit.htm
Aaron Young
Analyst Programmer
[email protected]
[email protected]
-
November 23rd, 1999, 02:36 AM
#5
Re: Create DSN with COM object
OK, Thanks.
I knew that one, but I was looking for a COM solution that I could use from an ASP.
Funny, the ODBCDSNTool seems to be completely undocumented...
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
|