How can I know how many lines were last inserted by Datagridview into Oracle
up vote
0
down vote
favorite
I'm programming an application that DataGridView should insert into Oracle after clicking a button. How can I know how many lines were last inserted into Oracle. At best a message should appear. Thanks
private void button4_Click(object sender, EventArgs e)
{
try
{
for (int i = 0; i < dataGridViewDoubleBuffered1.Rows.Count - 1; i++) //Schleife für INSERT Befehl
{
OracleConnection con = new OracleConnection(XXXXXXX);
con.Open();
string sql = "INSERT INTO AFTERSALES.INPUT_BOARDLEVEL_REPAIR_LDS (BLR_REPORT_DATE, MONTH_OF_REPAIR_END, PCB_COUNTER) "
+ "VALUES (:BLR_REPORT_DATE, :MONTH_OF_REPAIR_END, :PCB_COUNTER)";
OracleCommand cmd = new OracleCommand(sql, con);
cmd.CommandText = sql;
cmd.Parameters.Add(":BLR_REPORT_DATE", Convert.ToString(dataGridViewDoubleBuffered1.Rows[i].Cells[0].Value));
cmd.Parameters.Add(":MONTH_OF_REPAIR_END", dataGridViewDoubleBuffered1.Rows[i].Cells[1].Value);
cmd.Parameters.Add(":PCB_COUNTER", dataGridViewDoubleBuffered1.Rows[i].Cells[2].Value);
cmd.ExecuteNonQuery();
con.Close();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
c# winforms datagridview oracle11g
add a comment |
up vote
0
down vote
favorite
I'm programming an application that DataGridView should insert into Oracle after clicking a button. How can I know how many lines were last inserted into Oracle. At best a message should appear. Thanks
private void button4_Click(object sender, EventArgs e)
{
try
{
for (int i = 0; i < dataGridViewDoubleBuffered1.Rows.Count - 1; i++) //Schleife für INSERT Befehl
{
OracleConnection con = new OracleConnection(XXXXXXX);
con.Open();
string sql = "INSERT INTO AFTERSALES.INPUT_BOARDLEVEL_REPAIR_LDS (BLR_REPORT_DATE, MONTH_OF_REPAIR_END, PCB_COUNTER) "
+ "VALUES (:BLR_REPORT_DATE, :MONTH_OF_REPAIR_END, :PCB_COUNTER)";
OracleCommand cmd = new OracleCommand(sql, con);
cmd.CommandText = sql;
cmd.Parameters.Add(":BLR_REPORT_DATE", Convert.ToString(dataGridViewDoubleBuffered1.Rows[i].Cells[0].Value));
cmd.Parameters.Add(":MONTH_OF_REPAIR_END", dataGridViewDoubleBuffered1.Rows[i].Cells[1].Value);
cmd.Parameters.Add(":PCB_COUNTER", dataGridViewDoubleBuffered1.Rows[i].Cells[2].Value);
cmd.ExecuteNonQuery();
con.Close();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
c# winforms datagridview oracle11g
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm programming an application that DataGridView should insert into Oracle after clicking a button. How can I know how many lines were last inserted into Oracle. At best a message should appear. Thanks
private void button4_Click(object sender, EventArgs e)
{
try
{
for (int i = 0; i < dataGridViewDoubleBuffered1.Rows.Count - 1; i++) //Schleife für INSERT Befehl
{
OracleConnection con = new OracleConnection(XXXXXXX);
con.Open();
string sql = "INSERT INTO AFTERSALES.INPUT_BOARDLEVEL_REPAIR_LDS (BLR_REPORT_DATE, MONTH_OF_REPAIR_END, PCB_COUNTER) "
+ "VALUES (:BLR_REPORT_DATE, :MONTH_OF_REPAIR_END, :PCB_COUNTER)";
OracleCommand cmd = new OracleCommand(sql, con);
cmd.CommandText = sql;
cmd.Parameters.Add(":BLR_REPORT_DATE", Convert.ToString(dataGridViewDoubleBuffered1.Rows[i].Cells[0].Value));
cmd.Parameters.Add(":MONTH_OF_REPAIR_END", dataGridViewDoubleBuffered1.Rows[i].Cells[1].Value);
cmd.Parameters.Add(":PCB_COUNTER", dataGridViewDoubleBuffered1.Rows[i].Cells[2].Value);
cmd.ExecuteNonQuery();
con.Close();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
c# winforms datagridview oracle11g
I'm programming an application that DataGridView should insert into Oracle after clicking a button. How can I know how many lines were last inserted into Oracle. At best a message should appear. Thanks
private void button4_Click(object sender, EventArgs e)
{
try
{
for (int i = 0; i < dataGridViewDoubleBuffered1.Rows.Count - 1; i++) //Schleife für INSERT Befehl
{
OracleConnection con = new OracleConnection(XXXXXXX);
con.Open();
string sql = "INSERT INTO AFTERSALES.INPUT_BOARDLEVEL_REPAIR_LDS (BLR_REPORT_DATE, MONTH_OF_REPAIR_END, PCB_COUNTER) "
+ "VALUES (:BLR_REPORT_DATE, :MONTH_OF_REPAIR_END, :PCB_COUNTER)";
OracleCommand cmd = new OracleCommand(sql, con);
cmd.CommandText = sql;
cmd.Parameters.Add(":BLR_REPORT_DATE", Convert.ToString(dataGridViewDoubleBuffered1.Rows[i].Cells[0].Value));
cmd.Parameters.Add(":MONTH_OF_REPAIR_END", dataGridViewDoubleBuffered1.Rows[i].Cells[1].Value);
cmd.Parameters.Add(":PCB_COUNTER", dataGridViewDoubleBuffered1.Rows[i].Cells[2].Value);
cmd.ExecuteNonQuery();
con.Close();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
c# winforms datagridview oracle11g
c# winforms datagridview oracle11g
asked Nov 7 at 13:21
Yves
425
425
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
ExecuteNonQuery returns number of rows affected.
So,
var numRowsInserted = cmd.ExecuteNonQuery();
Thank you very much. Can you give me please a sample.
– Yves
Nov 7 at 13:29
@Yves - I provided a code sample already. If anything's not clear, feel free to ask. Note that since you are in a loop, you may need to add to the variable (e.g. numRowsInserted += cmd.ExecuteNonQuery()).
– dcp
Nov 7 at 13:32
add a comment |
up vote
0
down vote
int recordsAffected = cmd.ExecuteNonQuery();
From https://docs.microsoft.com/en-us/dotnet/api/system.data.oracleclient.oraclecommand.executenonquery?view=netframework-4.7.2:
Returns Int32 For UPDATE, INSERT, and DELETE statements, the return
value is the number of rows affected by the command.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
ExecuteNonQuery returns number of rows affected.
So,
var numRowsInserted = cmd.ExecuteNonQuery();
Thank you very much. Can you give me please a sample.
– Yves
Nov 7 at 13:29
@Yves - I provided a code sample already. If anything's not clear, feel free to ask. Note that since you are in a loop, you may need to add to the variable (e.g. numRowsInserted += cmd.ExecuteNonQuery()).
– dcp
Nov 7 at 13:32
add a comment |
up vote
0
down vote
ExecuteNonQuery returns number of rows affected.
So,
var numRowsInserted = cmd.ExecuteNonQuery();
Thank you very much. Can you give me please a sample.
– Yves
Nov 7 at 13:29
@Yves - I provided a code sample already. If anything's not clear, feel free to ask. Note that since you are in a loop, you may need to add to the variable (e.g. numRowsInserted += cmd.ExecuteNonQuery()).
– dcp
Nov 7 at 13:32
add a comment |
up vote
0
down vote
up vote
0
down vote
ExecuteNonQuery returns number of rows affected.
So,
var numRowsInserted = cmd.ExecuteNonQuery();
ExecuteNonQuery returns number of rows affected.
So,
var numRowsInserted = cmd.ExecuteNonQuery();
answered Nov 7 at 13:27
dcp
42.3k16118144
42.3k16118144
Thank you very much. Can you give me please a sample.
– Yves
Nov 7 at 13:29
@Yves - I provided a code sample already. If anything's not clear, feel free to ask. Note that since you are in a loop, you may need to add to the variable (e.g. numRowsInserted += cmd.ExecuteNonQuery()).
– dcp
Nov 7 at 13:32
add a comment |
Thank you very much. Can you give me please a sample.
– Yves
Nov 7 at 13:29
@Yves - I provided a code sample already. If anything's not clear, feel free to ask. Note that since you are in a loop, you may need to add to the variable (e.g. numRowsInserted += cmd.ExecuteNonQuery()).
– dcp
Nov 7 at 13:32
Thank you very much. Can you give me please a sample.
– Yves
Nov 7 at 13:29
Thank you very much. Can you give me please a sample.
– Yves
Nov 7 at 13:29
@Yves - I provided a code sample already. If anything's not clear, feel free to ask. Note that since you are in a loop, you may need to add to the variable (e.g. numRowsInserted += cmd.ExecuteNonQuery()).
– dcp
Nov 7 at 13:32
@Yves - I provided a code sample already. If anything's not clear, feel free to ask. Note that since you are in a loop, you may need to add to the variable (e.g. numRowsInserted += cmd.ExecuteNonQuery()).
– dcp
Nov 7 at 13:32
add a comment |
up vote
0
down vote
int recordsAffected = cmd.ExecuteNonQuery();
From https://docs.microsoft.com/en-us/dotnet/api/system.data.oracleclient.oraclecommand.executenonquery?view=netframework-4.7.2:
Returns Int32 For UPDATE, INSERT, and DELETE statements, the return
value is the number of rows affected by the command.
add a comment |
up vote
0
down vote
int recordsAffected = cmd.ExecuteNonQuery();
From https://docs.microsoft.com/en-us/dotnet/api/system.data.oracleclient.oraclecommand.executenonquery?view=netframework-4.7.2:
Returns Int32 For UPDATE, INSERT, and DELETE statements, the return
value is the number of rows affected by the command.
add a comment |
up vote
0
down vote
up vote
0
down vote
int recordsAffected = cmd.ExecuteNonQuery();
From https://docs.microsoft.com/en-us/dotnet/api/system.data.oracleclient.oraclecommand.executenonquery?view=netframework-4.7.2:
Returns Int32 For UPDATE, INSERT, and DELETE statements, the return
value is the number of rows affected by the command.
int recordsAffected = cmd.ExecuteNonQuery();
From https://docs.microsoft.com/en-us/dotnet/api/system.data.oracleclient.oraclecommand.executenonquery?view=netframework-4.7.2:
Returns Int32 For UPDATE, INSERT, and DELETE statements, the return
value is the number of rows affected by the command.
answered Nov 7 at 13:27
Miamy
604413
604413
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53190328%2fhow-can-i-know-how-many-lines-were-last-inserted-by-datagridview-into-oracle%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown