Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I connect to MySQL without ODBC?

Status
Not open for further replies.

paispatin

Technical User
Oct 21, 2003
62
A1
Dear all,

I would like to make server client database, the database server use MySQL.

I already make a VFP program to connect with MySQL, but it need ODBC (MyODBC) to connect the datase server.

Can I make it without ODBC, something like a code put at that program to connect MySQL server?

Thank you in advance.
 


To add to Mike's comment, you can do a search in forum184 for DNS-less connections (or search the internet). But I agree with Mike ODBC is easier.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
FYI: The "DSN-Less" connections still use ODBC, only without storing the ODBC Connection definition in the registry (or wherever Windows wants to put it), so you'd still need the ODBC driver.

I'm pretty sure that the way VFP connects to SqlServer is also using ODBC, unless you use the DMO objects.
 
Wgcs,

The "DSN-Less" connections still use ODBC, only without storing the ODBC Connection definition in the registry

Yes, I agree with that.

I'm pretty sure that the way VFP connects to SqlServer is also using ODBC, unless you use the DMO objects.

Well, it can also do so by means of OLE DB, but I think ODBC is more usual. Although paispatin's question related to MySQL, I would think the same considerations would apply as to SQL Server.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
I still don't "get" OLE DB... isn't it just an ActiveX wrapper for ODBC?

If not, what are the layers to OLE DB?

Does the SqlServer OLE DB ActiveX control have to be installed on a computer using OLE DB to get to SqlServer?

Is the MySql OLE DB ActiveX control different than a SqlServer OLE DB ActiveX control? Isn't the MySql OLE DB control something that would have to be installed on a client computer to get to MySql?


The way I understood it is that OLE DB defines the ActiveX interface, which is stored in an ActiveX control that is unique to the RDBMS, and the OLE DB control can use any method it wants (including ODBC, and File Sharing (VFP OLE DB), and direct Socket connection) to get to the RDBMS.
 
wgcs

Sorry I quickly did a search when the question was posted, and I didn't really read the text.
Microsoft said:
B. Connect to SQL Server without an existing ODBC data source
This example shows a call to SQLDriverConnect to connect to an instance of SQL Server without requiring an existing ODBC data source. By passing an incomplete connection string to SQLDriverConnect it causes the ODBC driver to prompt the user to enter the missing information.

#define MAXBUFLEN 255

SQLHENV henv = SQL_NULL_HENV;
SQLHDBC hdbc1 = SQL_NULL_HDBC;
SQLHSTMT hstmt1 = SQL_NULL_HSTMT;

SQLCHAR ConnStrIn[MAXBUFLEN] =
"DRIVER={SQL Server};SERVER=MyServer";

SQLCHAR ConnStrOut[MAXBUFLEN];
SQLSMALLINT cbConnStrOut = 0;

// Make connection without data source. Ask that driver
// prompt if insufficient information. Driver returns
// SQL_ERROR and application prompts user
// for missing information. Window handle not needed for
// SQL_DRIVER_NOPROMPT.
retcode = SQLDriverConnect(hdbc1, // Connection handle
NULL, // Window handle
ConnStrIn, // Input connect string
SQL_NTS, // Null-terminated string
ConnStrOut, // Address of output buffer
MAXBUFLEN, // Size of output buffer
&cbConnStrOut, // Address of output length
SQL_DRIVER_PROMPT);



Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Mike Gagnon,

Using SQLDriverConnect does not by-pass ODBC, as paispatin
requested. It merely avoids the need to create a DSN, as you suggested in your previous post.

paispatin,

Are you still here? You've had some good answers. How about answering some of the points raised?

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Wgcs,

I still don't "get" OLE DB... isn't it just an ActiveX wrapper for ODBC?

Not really. It's an alternative to ODBC. Just as you have a specific ODBC driver for a given database, you can have a specific OLE DB provider for a given database. However, one of the "databases" that OLE DB supports is ODBC. In other words, if there is no provider for a given database, you can use the generic ODBC provider instead. In that scenario, you are inserting an extra layer: client -> OLE DB -> ODBC -> database.

Although you raised some other interesting questions, they don't really address paispatin's problem. It would be really helpful if paispatin came back to tell us why he doesn't want to ODBC, and whether he is prepared to consider any alternatives.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Dear all,

Thank you very much for reply my problem, sorry I've to go out of town and just back here :)

MikeLewis, you right that ODBC is easy to use, but I just want to know how to or can I connect form VFP to MySQL without ODBC.

If I'm not wrong, VB can connect to MySQL server without ODBC. So, I think it also can do at VFP.

I already create a program with VFP to connect to MySQL, but I have to use MyODBC (from MySQL) to put at ODBC then every client have to install that file. That's why I think if VFP could connect to MySQL server without setting ODBC.

I ever got a code from VFP Tek-Tips forum (long time ago) to connect the MySQL server without ODBC, but I can not use that code. Is that because I use VFP 5?
Sorry, I will fine that code at my other hard drive, I will write it here if I get it later.

Thank you.
 
paispatin,

VB can connect to MySQL server without ODBC. So, I think it also can do at VFP.

I'm sure if VB can do it, VFP can as well.

I have to use MyODBC (from MySQL) to put at ODBC then every client have to install that file.

The client machine will already have ODBC installed on it (assuming it is a Windows machine). Your job will be to distribute the driver. That's not particularly difficult. You can install it along with the run time files for your application.

My advise would be not to spend too much time trying to avoid ODBC. It is probably is the simplest solution in this case.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
MikeLewis, thank's for your reply. Maybe you are right about to continue using ODBC for VFP. And that is really simple solution because I already did it :)

Thank you very much guys.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top