[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.odbcnet

SQLBindParameter not being called

Luke Stamm

7/16/2002 10:38:00 PM

I'm using ODBC.NET to access a Paradox 7 table. My
program can retrieve and update data in the table the
first time I access it in my program. However, when I
attempt to update the table a second time a
Microsoft.Odbc.OdbcException is raised stating:

Index: #0
Message: [Microsoft][ODBC Paradox Driver]COUNT field
incorrect.
Native: 17
Source: odbcjt32.dll
SQL: 07002

I ran an SQL trace and it shows that the first time my
update is called SQLBindParameter is called successfuly.
But when update the table a second time SQLBindParameter
is not called at all.

The function that makes the updates is as follows:

public string[] GenerateRequestIDs(string RetailerID, int
count) {
bool flag = true;
int PersonID;
string[] ret = new string[count];
System.Data.DataSet ds = new System.Data.DataSet
();

while(flag) {
try {
ds.ReadXmlSchema(MiscCISMM);
adapt_nextcust.Fill
(ds, "nextcust");
PersonID = (int) ds.Tables
["nextcust"].Rows[0][0];
for(int i=0; i<count; i++)
ret[i] = (PersonID + 1 +
i).ToString() + RetailerID[1] + RetailerID[3] + RetailerID
[4];
ds.Tables["nextcust"].Rows[0][0]
= PersonID + count;
adapt_nextcust.Update
(ds, "nextcust");
flag = false;
} catch(Microsoft.Data.Odbc.OdbcException
odbcException) {
for (int i=0; i <
odbcException.Errors.Count; i++) {
if
(System.Windows.Forms.MessageBox.Show("Index #" + i
+ "\n" + "Message: " + odbcException.Errors[i].Message
+ "\n" + "Native: " + odbcException.Errors
[i].NativeError.ToString() + "\n" + "Source: " +
odbcException.Errors[i].Source + "\n" + "SQL: " +
odbcException.Errors[i].SQLState + "\n" + "Would you like
to retry?" + "\n", "Access error",
System.Windows.Forms.MessageBoxButtons.RetryCancel,
System.Windows.Forms.MessageBoxIcon.Exclamation,
System.Windows.Forms.MessageBoxDefaultButton.Button1, 0) !
= System.Windows.Forms.DialogResult.Retry)
throw new
System.Exception("Failed to access table", odbcException);
}
}
}
ds = null;
return ret;
}

The update statement for adapt_nextcust is very basic:

UPDATE nextcust SET [NewCust] = ? WHERE [NewCust] = ?

The command object has two parameters set up, the first
parameter being the new value and the second being the
old value.

Any ideas?
Thanks.

Luke Stamm
1 Answer

Richard Stratford

7/31/2002 8:21:00 PM

0

I am also having exactly the same problem with a Sybase
table.

One way around the problem is to recreate the first
parameter of the insert command after calling
dataadapter.Update(dataset)

but this is obviously far from ideal.

Seems like a bug,
Regards,
Richard Stratford


>-----Original Message-----
>I'm using ODBC.NET to access a Paradox 7 table. My
>program can retrieve and update data in the table the
>first time I access it in my program. However, when I
>attempt to update the table a second time a
>Microsoft.Odbc.OdbcException is raised stating:
>
>Index: #0
>Message: [Microsoft][ODBC Paradox Driver]COUNT field
>incorrect.
>Native: 17
>Source: odbcjt32.dll
>SQL: 07002
>
>I ran an SQL trace and it shows that the first time my
>update is called SQLBindParameter is called successfuly.
>But when update the table a second time SQLBindParameter
>is not called at all.
>
>The function that makes the updates is as follows:
>
>public string[] GenerateRequestIDs(string RetailerID, int
>count) {
> bool flag = true;
> int PersonID;
> string[] ret = new string[count];
> System.Data.DataSet ds = new System.Data.DataSet
>();
>
> while(flag) {
> try {
> ds.ReadXmlSchema(MiscCISMM);
> adapt_nextcust.Fill
>(ds, "nextcust");
> PersonID = (int) ds.Tables
>["nextcust"].Rows[0][0];
> for(int i=0; i<count; i++)
> ret[i] = (PersonID + 1 +
>i).ToString() + RetailerID[1] + RetailerID[3] + RetailerID
>[4];
> ds.Tables["nextcust"].Rows[0][0]
>= PersonID + count;
> adapt_nextcust.Update
>(ds, "nextcust");
> flag = false;
> } catch(Microsoft.Data.Odbc.OdbcException
>odbcException) {
> for (int i=0; i <
>odbcException.Errors.Count; i++) {
> if
>(System.Windows.Forms.MessageBox.Show("Index #" + i
>+ "\n" + "Message: " + odbcException.Errors[i].Message
>+ "\n" + "Native: " + odbcException.Errors
>[i].NativeError.ToString() + "\n" + "Source: " +
>odbcException.Errors[i].Source + "\n" + "SQL: " +
>odbcException.Errors[i].SQLState + "\n" + "Would you like
>to retry?" + "\n", "Access error",
>System.Windows.Forms.MessageBoxButtons.RetryCancel,
>System.Windows.Forms.MessageBoxIcon.Exclamation,
>System.Windows.Forms.MessageBoxDefaultButton.Button1, 0) !
>= System.Windows.Forms.DialogResult.Retry)
> throw new
>System.Exception("Failed to access table", odbcException);
> }
> }
> }
> ds = null;
> return ret;
>}
>
>The update statement for adapt_nextcust is very basic:
>
>UPDATE nextcust SET [NewCust] = ? WHERE [NewCust] = ?
>
>The command object has two parameters set up, the first
>parameter being the new value and the second being the
>old value.
>
>Any ideas?
>Thanks.
>
>Luke Stamm
>.
>