List:MySQL ODBC« Previous MessageNext Message »
From:Steven Schoch Date:September 22 1999 4:45pm
Subject:Re: Question on iodbc/myodbc
View as plain text  
Federico Balbi wrote:

> > /* the insert statement */
> >     sprintf(query,"INSERT INTO prob_entry VALUES
> > (%d,'%s','%s','%s','%s','%s','%s','%s','%s','%s')",
> >                   problem.prob_num,
> >                   problem.prob_desc,
> >                   problem.prob_type,
> >                   problem.username,
> >                   problem.useremail,
> >                   problem.telephone,
> >                   problem.timeentered,
> >                   problem.closed,
> >                   problem.prob_user,
> >                   problem.prob_short_desc);
> >
> >   rc = SQLExecDirect(hstmt, query , SQL_NTS);
> >   check_return (rc, henv, hdbc, hstmt);
> > <end snip>
>
> Hi, I use VisualC++ and MySQL and upto now did not have problems.
> did you try to make a query manually and see what happens?
> try build the final string without sprint and see what happens...
> sometimes (",',%) act weird in MySQL.

It is wise to not assume the table will always have the columns in the same
order.  Change your query to this (assuming your column names are the same
as the fields in your structure):

sprintf(query,"INSERT INTO prob_entry (prob_num, prob_desc, prob_type,
username, useremail, telephone, timeentered, closed, prob_user,
prob_short_desc) VALUES (%d,'%s','%s','%s','%s','%s','%s','%s','%s','%s')",

--
Steven Schoch
StarNet Communications Corp.
1270 Oakmead Pkwy. #301
Sunnyvale, CA 94086  +1 408 739-0881



Thread
Question on iodbc/myodbcmoorleghen22 Sep
  • Question on iodbc/myodbcMichael Widenius22 Sep
  • Re: Question on iodbc/myodbcFederico Balbi22 Sep
    • Re: Question on iodbc/myodbcSteven Schoch22 Sep