Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
DataView/DataSet/DataReader
Message
De
08/01/2007 04:44:27
Dorin Vasilescu
ALL Trans Romania
Arad, Roumanie
 
 
À
08/01/2007 01:42:42
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Divers
Thread ID:
01183234
Message ID:
01183376
Vues:
35
>>
>>I would go with a DataReader and parametrized insert command.
>
>Hello Dorin.
>This is what I'm doing.

Hi
I'm an absolute beginner in NET, the only project I've done was this SqlServer CE/VFP,Sql Server Express test, to see if SSCE is good to be used as local data engine. So bear with me :)

What I've done was using parameters, see below, not tested:
.
.
.
        string lcStr1;
        string lcStr2;
        string lcStr3;
        double lnAmt;
        OleDbConnection concxn = new OleDbConnection(strConn);
        concxn.Open();

        OleDbCommand cmd = new OleDbCommand(strQuery, concxn);

        OleDbCommand cmdInsert = new OleDbCommand("insert into MyTarget (cust_id, Company, country, orderamt) values ( ?,?,?,? )", concxn);
	cmdInsert.Parameters.Add("customer_id", OleDbType.Integer,0);
	cmdInsert.Parameters.Add("company", OleDbType.VarChar,30);
	cmdInsert.Parameters.Add("country", OleDbType.VarChar,30);
	cmdInsert.Parameters.Add("orderamt", OleDbType.Numeric,0);
	cmdInsert.Prepare();

        OleDbDataReader readr = cmd.ExecuteReader();
        while (readr.Read())
        {
                cmdInsert.Parameters[0].Value = readr[0];
                cmdInsert.Parameters[1].Value = readr[1];
                cmdInsert.Parameters[2].Value = readr[2];
                cmdInsert.Parameters[3].Value = readr[3];
                cmdInsert.ExecuteNonQuery(); 
        }
.
.
.
HTH.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform