Need help with running an external SQL query from within VB.Net code.
I'm in a bit of a bind and new to SQL.
I have built a DB using the SQL Manager and it works perfectly in my code.
I have used SQL Manager to build the SQL to rebuild my DB as I want to use it in my VB.Net code.
When I execute this SQL in the SQL management studio it works 100 %.
When I execute it in code I get an error: The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. The RPC name is invalid."
All I'm trying to do is build the DB in code. I looked up the error in Google and there was one response which made no sense at all.
DBNew = "Server=" & DBServer & "\SQLEXPRESS;Integrated Security=True;database=master"
Dim objConn As New SqlConnection(DBNew)
Try
objConn.Open()
Catch ex As Exception
MsgBox(ex.Message)
End Try
Dim sr As StreamReader = New StreamReader("C:\Development\PureMatrix\PureMatrix\Scripts\buildDB.sql")
Dim script As String = sr.ReadToEnd
Try
Dim objCmd As New SqlCommand(script, objConn)
MsgBox(script)
objCmd.CommandType = CommandType.StoredProcedure
objCmd.ExecuteNonQuery()
catch
end try



