Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Database and Reporting > SQL Execution Results


Reply
 
Thread Tools Display Modes
  #1  
Old 07-19-2004, 08:04 AM
VeRiTo's Avatar
VeRiTo VeRiTo is offline
Contributor
 
Join Date: Nov 2003
Location: Buenos Aires
Posts: 614
Question SQL Execution Results



hi people! In MS SQL Server 8 (query analyzer) when
i execute a query (insert/update/delete) i get the message '2 rows affected'. I wonder how to know how many records have been affected when i execute the query from VB6 using Ado.
Example:

Code:
Dim CnDB as New ADODB.Connection CnDB.Open ..... .... CnDB.Excute "UPDATE Articles SET ArtName='xName' WHERE ArtCod<100;" Msgbox "5 Records affected!"

Thanks in advanced!!!
__________________
.:.VeRiTo.:.
Reply With Quote
  #2  
Old 07-19-2004, 08:06 AM
Dennis DVR's Avatar
Dennis DVR Dennis DVR is offline
Back in the Game

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Manila Philippines
Posts: 3,555
Default

i think execute method has a another parameter that you can pass to get the number of rows affected by the process
__________________
Avatar by Lebb

[Posting Guidelines] [Standards & Practices Tutorial] [Participate here effectively]
Our knowledge can only be finite, while our ignorance must necessarily be infinite. Karl Popper

Last edited by duane; 07-19-2004 at 08:15 AM. Reason: Replace second with another
Reply With Quote
  #3  
Old 07-19-2004, 08:18 AM
MKoslof's Avatar
MKoslof MKoslof is offline
Cum Grano Salis

Retired Moderator
* Guru *
 
Join Date: Jul 2002
Location: Baltimore, Maryland
Posts: 14,636
Default



Code:
Dim iaffected As Long iaffected = 0 'your insert or update statement here strString = "INSERT INTO myTable SELECT....." 'where cn is your open, active ADO connection cn.Execute strString, iaffected 'return the number of recs affected If iaffected > 0 Then MsgBox "records added: " & iaffected End If
__________________
"Artificial Intelligence is no match for natural stupidity." ~unknown
Reply With Quote
  #4  
Old 07-19-2004, 08:25 AM
VeRiTo's Avatar
VeRiTo VeRiTo is offline
Contributor
 
Join Date: Nov 2003
Location: Buenos Aires
Posts: 614
Default

oh! thanks a lot!!!
__________________
.:.VeRiTo.:.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->