Click to See Complete Forum and Search --> : Create DSN with COM object
Lothar Haensler
November 19th, 1999, 08:21 AM
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.
Aaron Young
November 19th, 1999, 12:04 PM
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
adyoung@win.bright.net
aarony@redwingsoftware.com
Lothar Haensler
November 22nd, 1999, 01:50 AM
your code works very well.
Do you know how to change it to create a system DSN?
Aaron Young
November 22nd, 1999, 01:32 PM
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/psdk/dasdk/odch3kit.htm
Aaron Young
Analyst Programmer
adyoung@win.bright.net
aarony@redwingsoftware.com
Lothar Haensler
November 23rd, 1999, 01:36 AM
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...
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.