Link to home
Start Free TrialLog in
Avatar of marvelsoft
marvelsoftFlag for Philippines

asked on

ADODB cn.Execute

Experts,

Please help me to correct this code.
Codes to insert new record.
=====================================================================================
            string oConn, StrSql;
            ADODB.Connection cn = new ADODB.Connection();

            oConn = "Driver={MySQL ODBC 3.51 Driver};Server=xxx.xxx.xxx.xxx;Port=3306;Option=131072;Stmt=;Database=database;Uid=ADMIN;Pwd=pwrd";
            StrSql = "insert into names (code, name) values ('00001', 'This is a test.')";

            cn.Open(oConn, null, null, 0);
            cn.Execute(StrSql, ?, ?);

            cn.Close();
=====================================================================================

Thanks,

SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dstanley9
dstanley9

1) Why are you using ADODB instead of ADO.NET?
2) You must include System.Reflection.Missing for optional parameters:

System.Reflection.Missing missing = System.Reflection.Missing.Value;
cn.Open(oConn, null, null, 0);
cn.Execute(StrSql, ref missing, ref missing);
Avatar of marvelsoft

ASKER

It is just happens to that my old programs is written in VB6 w/ ADODB, but Im started converting it to VS2005.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial