Hi,
Somebody please help me how can i rum a .sql file from vc++. Iam using
MFC with MySQL as backend.

Re: How can I run '.sql' script from vc++ by Eric

Eric
Tue Feb 27 09:25:50 CST 2007

> Hi,
> Somebody please help me how can i rum a .sql file from vc++. Iam using
> MFC with MySQL as backend.

Use CreateProcess or ShellExecute to launch the following:

mysql my_db_name -umy_user_name -pmy_password my_script.sql

If you need to get access to the database instead of just running a
script, a good place to start would be the C++ wrapper around the mysql C
API, called MySQL++.

Find it here: http://tangentsoft.net/mysql++/

Eric

Re: How can I run '.sql' script from vc++ by sujeeshlal

sujeeshlal
Wed Feb 28 01:03:29 CST 2007

Thanks Eric for ur help.

I have an 'Insert.sql' script in my source directory. On that Sql
file ,Iam trying to insert a value to a table.
I tried like this

ShellExecute(NULL, "open", "mysql", "mydb -u root -p root
Insert.sql", NULL, SW_SHOW);

But its not working..Where am I worng..

pls help





On Feb 27, 7:25 pm, "Eric Hill" <e...@ijack.net> wrote:
> > Hi,
> > Somebody please help me how can i rum a .sqlfile from vc++. Iam using
> > MFC with MySQL as backend.
>
> Use CreateProcess orShellExecuteto launch the following:
>
> mysql my_db_name -umy_user_name -pmy_password my_script.sql
>
> If you need to get access to the database instead of just running a
> script, a good place to start would be the C++ wrapper around the mysql C
> API, called MySQL++.
>
> Find it here:http://tangentsoft.net/mysql++/
>
> Eric



Re: How can I run '.sql' script from vc++ by Eric

Eric
Wed Feb 28 09:33:16 CST 2007

> I have an 'Insert.sql' script in my source directory. On that Sql
> file ,Iam trying to insert a value to a table.
> I tried like this
>
> ShellExecute(NULL, "open", "mysql", "mydb -u root -p root
> Insert.sql", NULL, SW_SHOW);
>
> But its not working..Where am I worng..

What makes you think that it's not working, besides the row never getting
inserted? Can you run it manually and get it to work? Do you get an
error message?

Eric

Re: How can I run '.sql' script from vc++ by beginthreadex

beginthreadex
Thu Mar 01 09:40:17 CST 2007

Load the .sql file into a string, parse by the word "go" so you can
execute blocks. Then open a connection to SQL and Execute each parsed
block into SQL. If you shell, there is no way to know if you have osql
installed or not. Just use ADO for MFC equ.

On 27 Feb 2007 05:40:21 -0800, sujeeshlal@gmail.com wrote:

>Hi,
>Somebody please help me how can i rum a .sql file from vc++. Iam using
>MFC with MySQL as backend.