Sunday, February 26, 2012

Error Message with Recordset.Update

Hi,

I am converting a VB6 application to C# using ADO. I have the following code:

private ADODB.Connection cn = new ADODB.Connection();
private ADODB.Recordset rs = new ADODB.Recordset();

private connectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data source= " + stdDir;
strClientSQL = "SELECT * FROM Client ORDER BY casename, renldate, product, fundingcode";

cn.CursorLocation = ADODB.CursorLocationEnum.adUseClient;
cn.Open(Utilities.connectionString,null,null,0);

rs.CursorLocation = ADODB.CursorLocationEnum.adUseServer;
rs.Open(strClientSQL,cn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic,-1);

rs.Fields["CaseName"].Value = this.txtCaseName.Text;

rs.Fields["CaseNo"].Value = this.txtCaseNumber.Text;

rs.Update();

When I try to compile and run it I get the following error message:

"No overload for method 'Update' takes '0' arguments"

I am not sure if I need to enter information in the update command or do something else. This seems pretty straight forward but I can't figure out how to do it. Can someone please help me?

Thanks,

Mark

The thing is that you have to place the fieldas and its values in the function, like this:

rsMsg.Update("Field1,Field2,Field3", "Value1,Value2,Value3");

But i supossed that you want to update the whole recordset, am i rigth?
That's a good question.... give me some time to answer that.

Hugo|||try without the parenthesis

rs.Update

No comments:

Post a Comment