c# - How to use a SqlDataReader result as a MySqlParameter value -



c# - How to use a SqlDataReader result as a MySqlParameter value -

i'm moving tables sql server db mysql db programmatically.

i've got sqldatareader populated table's fields values, , insert them corresponding mysql table. there aren't primary key , auto increment problems on destination table.

what i'm missing howo convert sqldatareader field value mysqlparameter value. snippet of code:

cmd.commandtext = "select a,b,c,d,e sqltable"; cmd.prepare(); dr = cmd.executereader(); while (dr.read()) { mysqlconnection mysqlconn = new mysqlconnection(mysqlconnstring); mysqlconn.open(); mysqlcmd.connection = mysqlconn; mysqlcmd.commandtext = "insert mysqltable values (?, ?, ?, ?, ?) "; (int k = 0; k < dr.fieldcount; k++) { mysqlcmd.parameters.add(new mysqlparameter(dr[k].tostring(), dr[k])); } ...

a fatal error occurs on line, without detail.

mysqlcmd.parameters.add(new mysqlparameter(dr[k].tostring(), dr[k]));

i cannot understand how set dr[k] value acceptable mysql.

c# mysql-connector

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -