Note that there are some explanatory texts on larger screens.

plurals
  1. POConnection String For Local and Remote MSSQL SQL Insert Into
    primarykey
    data
    text
    <p>I have this code that will insert into the data from one table to another. The problem, is I am now trying to insert into a table from remote mssql server to my local mssql server. How will be the sql script for it, using VB.net?</p> <p>I am presently getting an error:</p> <blockquote> <p>network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)</p> </blockquote> <p>This is my code as of the moment:</p> <pre><code>Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim rowsAffected As Integer = 0 Dim myConnectionString = "Data Source=(IP Address),1433;Network Library=DBMSSOCN;Initial Catalog=dbase;User ID=sa;Password=password;" Dim myconnectionstring2 = "Data Source= PC-Name;Initial Catalog=dbase;Integrated Security=True;Pooling=False" 'Dim myConnection As New SqlConnection(myConnectionString) Dim myQuery As String = "INSERT INTO dbase.dbo.tbltransactions1 SELECT * FROM dbase.dbo.tbltransactions1" 'Dim myQuery As String = "insert INTO (table)" 'select 'from LinkedserverName.DatabaseName.SchemaName.TableName" Dim myCommand As New SqlCommand(myQuery, myConnection, myConnection2) Try myConnection.Open() rowsAffected = myCommand.ExecuteNonQuery() Catch ex As Exception MsgBox(" ") Finally myConnection.Close() End Try Label1.Text = rowsAffected.ToString() End Sub </code></pre> <p>*The connection string that has an IP address is the server I want to connect while the other one is the connection string for my local server..</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload