I've been searching but have not found a good example of what i need to accomplish. The title says it all. This is what i have so far:
//gather the report details
DataTable dtReturn = new DataTable();
DataTable dtResults = new DataTable();
string strScript = "";
bool doReturnData = false;
try
{
//this function returns my SQL table in to a datatable dtReturn:
var ii =
Utility.db.Connection.EstablishDBConnection("usp_get_data_recap", dtReturn, null, null, true, 60);
//Clear out table before insert
dtResults = OracleDataPull(9, "TRUNCATE TABLE user.SIGNUP_1");
OracleParameter myparam = new OracleParameter();
OracleCommand mycommand = new OracleCommand();
int n;
//bulk insert to the signup_1 table from the datatable members. Datatable contains the same 4 fields being inserted in to signup_1 on the oracle side:
mycommand.CommandText = "INSERT INTO user.SIGNUP_1 ([ID], [ACCOUNT_NUMBER], [MAIN_CUSTOMER], [SIGNUP_DATE]) VALUES(?)";
mycommand.Parameters.Add(myparam);
for (n = 0; n < 100000; n++)
{
[what do i do here?]
}
}
I am not sure if this is correct, or if there is an easier way, but i need to map dtReturn.Rows[n][0-3] to ID, account_number, main_customer, and signup_date respectively.
Help is very apprecaited! Thanks in advance!
edit:
i tried the suggestion below, but am getting an error with the lambda expression: "Cannot convert lambda expression to type 'string' because it is not a delegate type" :
var ii =
Utility.db.Connection.EstablishDBConnection("usp_get_data", dtReturn, null, null, true, 60);
dtResults = OracleDataPull(9, "TRUNCATE TABLE user.PR_data");
OracleParameter myparam = new OracleParameter();
OracleCommand mycommand = new OracleCommand();
mycommand.ArrayBindCount = dtReturn.Rows.Count;
mycommand.Parameters.Add(":myparam", OracleDbType.Varchar2, dtReturn.Select(c => c.myparam).ToArray(), ParameterDirection.Input);
mycommand.ExecuteNonQuery();
int n;
mycommand.CommandText = "INSERT INTO user.PR_data ([ID], [ACCOUNT_NUMBER], [MAIN_CUSTOMER], [SIGNUP_DATE]) VALUES(?)";
mycommand.Parameters.Add(myparam);
for (n = 0; n < 100000; n++)
{
myparam.Value = n + 1;
mycommand.ExecuteNonQuery();
}
dtResults = Utility.db.Connection.oracletoDataTable(strScript, doReturnData);
I am also not sure this is set up to produce the correct results. Can you please advise where i am going wrong here?