Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calling the ODBC dialog
Message
From
01/04/1999 16:36:52
 
 
To
01/04/1999 15:54:00
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00204397
Message ID:
00204461
Views:
19
Todd...

Thanks for your reply. I thought about doing it this way, but this doesn't allow the user to create a new connection on the fly.

I've seen some applications that manage this, but all have been written in either VB or Access. I'm assuming there's an API call to this dialog, and some kind of return value that equates to the connection handle created, but no luck so far.

Scott

>I do this. I bet someone else has a better way:
>
>
>create cursor datasource (sourcename c(50), sourcedesc c(100), count n(3))
>ODBCFILEHANDLE=FOPEN("C:\WINDOWS\ODBC.INI")
>IF ODBCFILEHANDLE < 1 THEN
>	WAIT WINDOW "Can't open odbc file.  Can't find c:\windows\odbc.ini.  Call Todd."
>	return
>endif
>found_start_point = .f.
>do while !found_start_point and !feof(odbcfilehandle)
>	found_start_point = fgets(odbcfilehandle) # '[ODBC 32 bit Data Sources]'
>enddo
>if feof(odbcfilehandle) then
>	wait window "Can't find ODBC section of c:\windows\odbc.ini.  Call Todd."
>	return
>endif
>modbcline = space(20)
>m.count = 999
>do while !feof(odbcfilehandle)
>	odbcline = fgets(odbcfilehandle)
>	if odbcline = '[ODBC 32 bit Data Sources]' then
>		loop
>	endif
>	if odbcline = '[' then
>		exit
>	endif
>	msourceequalpos = at("=", odbcline)
>	m.sourcename = left(odbcline, msourceequalpos - 1)
>	m.sourcedesc = substr(odbcline, msourceequalpos + 1)
>	insert into datasource from memvar
>	m.count = m.count - 1
>enddo
>public datasource[1]
>select * from datasource where sourcename # [ ] order by count into array datasource
>use in datasource
>mclose = fclose(odbcfilehandle)
>if !mclose then
>	wait window "Can't close ODBC file.  Call Todd."
>	return
>endif
>
>
>
>
>>Hey, all:
>>
>> Does anybody know how to either a)build a list of ODBC connections defined to the system, and b)call the Windows ODBC dialog to allow the user to either choose or define a connection, and then return some handle for the connection they've chosen?
>>
>>TIA...
>>
>>Scott
Scott D. Grabo
Chief Information Officer
Occupational Health Group
First Advantage Corporation
Previous
Reply
Map
View

Click here to load this message in the networking platform