No. of row effected in Update/Insert Query
Hi again,
Dear all, I am again in trouble with my project of billing solution.
In my project I have used some update and insert queries which modifies the raw data to calculate some billing effects. I want to show the number of rows effected on each update or insert query.
e.g. If I use insert query, it will insert the data into table (lets say 5 records). after completion of insert query i want to display the "5" in label1.caption
Short solution will be highly appreciated.
Umar
Re: No. of row effected in Update/Insert Query
Post your code so we can see where the problem *might* be
Re: No. of row effected in Update/Insert Query
Use an ADO connection object to .Execute the sql statement against your database. The second argument is the number or records affected.
Code:
Dim oCnn As ADODB.Connection
Dim lRecs As Long
Set oCnn = New ADODB.Connection
oCnn.Connectionstring"Your connectionstring to your database etc"
oCnn.Open
'Then execute your insert sql
oCnn.Execute "INSERT INTO Table1 VALUES('Test', 'Test2', Test3')", lRecs
label1.caption = lRecs & " Record(s) added to the database."
Re: No. of row effected in Update/Insert Query
working, u r gr8
can we do the same for select quries.
Re: No. of row effected in Update/Insert Query
With a select query you would be opening a recordset with the select statement as your source so you would depend on the .RecordCoutn property if your peovider supports it.