J
joun
Hi all, i'm using this code to insert records into an Access table from
asp.net, using a
stored procedure, called qry_InsertData:
PARAMETERS [pID] Long, [pCod] Long, [pCodArt] Text(20), [pQ1] Long,
[pDataUscita] DateTime;
INSERT INTO Table ( ID, Cod, CodArt, Q1, DataUscita )
VALUES (pID, pCod, pCod, pQ1, pDataUscita);
this is my c# code:
OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM Table", conn);
DataSet ds = new DataSet();
// The table is initially empty, so ds has no rows
da.Fill(ds, "Table");
OleDbCommand upCmd = new OleDbCommand("qry_InsertData", conn);
upCmd.CommandType = CommandType.StoredProcedure;
upCmd.Parameters.Add("pID", OleDbType.Integer, 0, "ID");
upCmd.Parameters.Add("pCod", OleDbType.Integer, 0, "Cod");
upCmd.Parameters.Add("pCodArt", OleDbType.VarChar, 20, "CodArt");
upCmd.Parameters.Add("pQ1", OleDbType.Integer, 0, "Q1");
upCmd.Parameters.Add("pDataUscita", OleDbType.Date, 0, "DataUscita");
da.InsertCommand = upCmd;
// Insert many new rows into the dataset
while (-------)
{
vett = ........
ds.Tables["Table"].Rows.Add(
new object[] {vett[0], vett[1], vett[2], vett[3], vett[4], vett[5]});
}
da.Update(ds, "Table");
Now the strange thing: the update process terminates successfully, in the
Table i can see the new rows,
but all records have the same values of the first one, except for the field
CodArt, correctly updated
Example:
ID Cod CodArt Q1 DataUscita
435 46669 1071-B 3 24/11/2004
435 46669 1071-N 3 24/11/2004
435 46669 1072-N 3 24/11/2004
435 46669 1073-N 3 24/11/2004
435 46669 1075-B 3 24/11/2004
435 46669 1076-N 3 24/11/2004
.........
only the CodArt field is correct, all other fields are duplicated.
So where is the problem???? It is a BUG???
Thanks,
Michele
PS: if i replace the upCmd "qry_InsertData" with the entire sql statement,
i.e. without calling the stored procedure,
all things works fine, but slower.
asp.net, using a
stored procedure, called qry_InsertData:
PARAMETERS [pID] Long, [pCod] Long, [pCodArt] Text(20), [pQ1] Long,
[pDataUscita] DateTime;
INSERT INTO Table ( ID, Cod, CodArt, Q1, DataUscita )
VALUES (pID, pCod, pCod, pQ1, pDataUscita);
this is my c# code:
OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM Table", conn);
DataSet ds = new DataSet();
// The table is initially empty, so ds has no rows
da.Fill(ds, "Table");
OleDbCommand upCmd = new OleDbCommand("qry_InsertData", conn);
upCmd.CommandType = CommandType.StoredProcedure;
upCmd.Parameters.Add("pID", OleDbType.Integer, 0, "ID");
upCmd.Parameters.Add("pCod", OleDbType.Integer, 0, "Cod");
upCmd.Parameters.Add("pCodArt", OleDbType.VarChar, 20, "CodArt");
upCmd.Parameters.Add("pQ1", OleDbType.Integer, 0, "Q1");
upCmd.Parameters.Add("pDataUscita", OleDbType.Date, 0, "DataUscita");
da.InsertCommand = upCmd;
// Insert many new rows into the dataset
while (-------)
{
vett = ........
ds.Tables["Table"].Rows.Add(
new object[] {vett[0], vett[1], vett[2], vett[3], vett[4], vett[5]});
}
da.Update(ds, "Table");
Now the strange thing: the update process terminates successfully, in the
Table i can see the new rows,
but all records have the same values of the first one, except for the field
CodArt, correctly updated
Example:
ID Cod CodArt Q1 DataUscita
435 46669 1071-B 3 24/11/2004
435 46669 1071-N 3 24/11/2004
435 46669 1072-N 3 24/11/2004
435 46669 1073-N 3 24/11/2004
435 46669 1075-B 3 24/11/2004
435 46669 1076-N 3 24/11/2004
.........
only the CodArt field is correct, all other fields are duplicated.
So where is the problem???? It is a BUG???
Thanks,
Michele
PS: if i replace the upCmd "qry_InsertData" with the entire sql statement,
i.e. without calling the stored procedure,
all things works fine, but slower.