Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Server Remote ADO Debuger - A simple way to "see" ...
Author:
Gelu Gogancea
E-mail:
Click to e-mail author
Submitted:
12/23/2000
Version:
VB5
Compatibility:
VB5, VB6
Category:
Databases
Views:
8838
Server Remote ADO Debuger - A simple way to "see" what happend on the server if you use unstored procedure.In this sample code is a unstored SQL procedure and the ADOMyDebug Code.
Declarations:
'none
Code:
Public Sub MyTest() Dim MyDb As ADODB.Recordset Dim MyDbCmd As ADODB.Command Dim MyDbCon As ADODB.Connection Set MyDbCon = New ADODB.Connection MyDbCon.ConnectionString = "DSN=MyDSN;" MyDbCon.Open Set MyDbCmd = New ADODB.Command Set MyDbCmd.ActiveConnection = MyDbCon Set MyDb = New ADODB.Recordset 'Unstored procedure MyDbCmd.CommandText = "SET @A=0;" 'Initialize @A MyDbCmd.CommandType = adCmdText MyDbCmd.Execute 'If you don't expect result MyDbCmd.CommandText = "SELECT @A=MAX(ID) from MyTable;" 'Get the MAXimum value from ID column MyDbCmd.CommandType = adCmdText MyDbCmd.Execute MyDbCmd.CommandText = "SELECT CASE WHERE @A IS NULL THEN @A:=1 ELSE @A:=@A+1;" 'If A is null then A=1 else A=A+1, like autoincrement MyDbCmd.CommandType = adCmdText 'Last query remain unexecuted because MyDebug must do this MyDebug MyDbCmd, MyDb, MyDbCon, "Case @A IS NULL THEN @A:=1 ..." 'Now must "see" what happend on the server MyDb.Close MyDbCon.Close End Sub Public Sub MyDebug(Comanda As ADODB.Command, Record As ADODB.Recordset, Con As ADODB.Connection, Reference As String) Dim aa As String, a As Long Record.ActiveConnection = Con Record.CursorLocation = adUseClient Record.CursorType = adOpenDynamic Set Record = Comanda.Execute() 'If you expect results With Record If .EOF = True Then aa = "No Result !" Raspuns = MsgBox("SQL CODE Debug:" & Reference & vbCr & aa, vbInformation, "MyDebug") Exit Sub End If Do While .EOF = False a = (a + 1) - 1 aa = aa + Trim(.Fields(0)) & vbCr .MoveNext Loop End With Raspuns = MsgBox("SQL CODE Debug :" & Reference & vbCr & aa, vbInformation, "MyDebug") End Sub
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2023 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement