July 16, 2008 at 3:12 am
hi there,
i have a problem with the ExecuteWithResultsAndMessages command executed in a vbs script.
the following statements becomes the resultset in in the tblResult1 object but the expected message, like 'nn rows affected', is missing.
i tried every syntax (also the ExecuteWithResultsAndMessages2 command) but nothing gives me the message.
does anyone have an idea what i make wrong.
searching aroung the internet or microsoft or anything else doesnt help me.
Set objSQLServer1 = CreateObject("SQLDMO.SQLServer")
objSQLServer1.LoginSecure = True
objSQLServer1.LoginTimeout = 3
objSQLServer1.Connect "sqlserver"
Set objDB1 = objSQLServer1.Databases("sqldatabase")
tblQuery1 = "SELECT * from sqltable"
Set tblResult1 = objSQLServer1.ExecuteWithResultsAndMessages(tblQuery1, sMessages, Len(tblQuery1))
regards
Michael
August 1, 2008 at 6:14 pm
Hi,
I have not much idea of the DMO. But why dont you use the records count of the resulting table?
You can try:
tblResult1.RecordsCount
I hope this will be helpful to you.
Nilesh.
August 2, 2008 at 1:48 am
the 'nn rows affected' message was only a little sample for what i mean.
the really important messages like error messages and so on are the real background on this question.
greetz
Michael
August 16, 2008 at 3:04 am
Hi,
I usually display the errors through a try and catch;
Try
//Your code
db.ExecuteWithResults(//Script)
Console.WriteLine("Execution completed without any error(s)")
Catch ex As FailedOperationException
Dim err As SqlClient.SqlException = CType(CType(ex.InnerException, ExecutionFailureException).InnerException, SqlClient.SqlException)
Console.Writeline("Line " & err.LineNumber & " Message " & err.Message & " Error " & err.Number & " State " & err.State & vbCrLf)
End Try
Hope this helps!
Regards,
Matt
October 8, 2009 at 10:46 am
one year has gone but the problem is the same.
so i like to ask again, if anyone has a working VBS with the DMO command "ExecuteWithResultAndMessage" where the results and also the messages comes back.
kind regards
Michael
October 9, 2009 at 3:57 am
Is there a compelling need to do it in VBS? If you can use .NET then it's relatively easy - there's an event on SqlConnection that you just hook on to...
Atlantis Interactive - SQL Server Tools
My blog[/url]
Why I wrote a sql query analyzer clone
October 9, 2009 at 9:19 am
yes, unfortunately there is a need for vbs because i have about 13000 lines of code in a HTA (vbs/wmi) and i dont want to recode this in another language, which i furthermore not be able to code.
bye
Michael
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply