Import the table in the DataSet into the database table

zhaozj2021-02-16  72

I am like this to import the table in the DataSet into the database table:

Oconn = new sqlconnection; oconn.open ();

// SRCDS to import DataSet

// DSTable: a table name in SCRDS

// szdasql query statement (SELECT * FROM database table)

public DataSet ImportToDBTable (DataSet srcDS, string szDASQL, string dsTable) {DataSet myDS = new DataSet (); SqlDataAdapter sqlDA = new SqlDataAdapter (szDASQL, oConn); sqlDA.Fill (myDS, dsTable); SqlCommandBuilder sqlcommandbuilder = new SqlCommandBuilder (sqlDA) DataRow mydatarow2 = null; try {for (int J = 0; j

} Myds.tables [dstable] .Rows.add (MyDataRow2); Sqlda.Update (MyDS, DSTABLE);

} Catch {Return Null;} Return MYDS;

}

The method is more stupid, please advise.

转载请注明原文地址:https://www.9cbs.com/read-17536.html

New Post(0)