Background. I want to be able to run any non results returning sql statements, mostly create and drop stored procedures on multible servers without having to do it in q analyzer since we have a large amount of servers and it is time consuming to do it that way. Its all the same db, username and password, only the server changes.
so i have a table that lists my servers that i loop through the selected servers. It works great sometimes... For simple regular sql it works good like Inserts, updates it does some stored procedures. I can create simple ones. Seems to have a problem with go. Im pretty sure my code is correct since it does work sometimes. But i want it to be able to work all the time. The error it gives is "An unhandled exception of type 'System.NullReferenceException' occurred in MultiAnalyzer.exe
Additional information: Object reference not set to an instance of an object." It seems to be a general sql problem. Anyone have ideas? Also if anyone has a different way to do it, please feel free to suggest it.
Servername and strtext are passed in text being the sql statement.
Dim con As New SqlConnection("data source=" & Servername & ";initial catalog=Softwise;password="""";persist security i" & _
"nfo=True;user id=sa;packet size=4096"
Dim cmd As New SqlCommand(Trim(strText), con)
Dim intRows As Integer
Try
cmd.Connection.Open()
intRows = cmd.ExecuteNonQuery()
Catch
Dim aE As SqlException
MessageBox.Show(aE.Message.ToString())
End Try
con.Close()
Thanks for any help provided
so i have a table that lists my servers that i loop through the selected servers. It works great sometimes... For simple regular sql it works good like Inserts, updates it does some stored procedures. I can create simple ones. Seems to have a problem with go. Im pretty sure my code is correct since it does work sometimes. But i want it to be able to work all the time. The error it gives is "An unhandled exception of type 'System.NullReferenceException' occurred in MultiAnalyzer.exe
Additional information: Object reference not set to an instance of an object." It seems to be a general sql problem. Anyone have ideas? Also if anyone has a different way to do it, please feel free to suggest it.
Servername and strtext are passed in text being the sql statement.
Dim con As New SqlConnection("data source=" & Servername & ";initial catalog=Softwise;password="""";persist security i" & _
"nfo=True;user id=sa;packet size=4096"
Dim cmd As New SqlCommand(Trim(strText), con)
Dim intRows As Integer
Try
cmd.Connection.Open()
intRows = cmd.ExecuteNonQuery()
Catch
Dim aE As SqlException
MessageBox.Show(aE.Message.ToString())
End Try
con.Close()
Thanks for any help provided