Need help with running an external SQL query from within VB.Net code.

5 pts.
Tags:
SQL Express
SQL Manager
SQL Server errors
VB.NET
Hi all, 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:DevelopmentPureMatrixPureMatrixScriptsbuildDB.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

Answer Wiki

Thanks. We'll let you know when a new response is added.

I suspect that this might be a problem sending a unicode string to sql server 2005 driver when it is hoping for an ansi string – assuming the error occurs when you call ExecuteNonQuery

If so, try using System.Text.Encoding.Convert static method to convert to ansi first

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following