Good morning,
I'm a problem with my VB.Net and SQL.
My test code is:
I get the values from one SQL SERVER, using conexaoRcsoft
Then, I need insert one ore more tables into another SQL SERVER, using the conexaoBD.
Can I insert the dataset or datatable into my new SQL server database?
How???
The server are the same, but the databases are diferent.
I try many solutions, but none of them works
I'm a problem with my VB.Net and SQL.
My test code is:
Code:
Dim ConexaoRcsoft, ConexaoDB As SqlConnection
Dim DsDados As DataSet
Dim Dt As DataTable
Dim sqlString As String = "SELECT taxa,descricao FROM dbo.taxa"
ConexaoRcSoft = New SqlConnection(connStrinRcSoft)
ConexaoDB = New SqlConnection(connString)
Dim AdaptadorDados As SqlDataAdapter = New SqlDataAdapter(sqlString, ConexaoRcsoft)
DsDados = New DataSet()
AdaptadorDados.Fill(DsDados, "taxa")
Dt = DsDados.Tables("taxa")
ConexaoDB.Open()
Dim sc As New SqlCommand(
"INSERT INTO dbo.teste (taxa, descricao)" &
"SELECT taxa, descricao FROM @taxa;", ConexaoDB)
sc.Parameters.AddWithValue("@taxa", DsDados)
sc.ExecuteNonQuery()
MsgBox(Dt.Rows.Count)
ConexaoDB.Close()
Then, I need insert one ore more tables into another SQL SERVER, using the conexaoBD.
Can I insert the dataset or datatable into my new SQL server database?
How???
The server are the same, but the databases are diferent.
I try many solutions, but none of them works