Click here to Skip to main content
15,890,336 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
#This is my localhost connectionstring
VB
con.ConnectionString = "Driver={MySQL ODBC 3.51 Driver};database=schemalocal;option=0;port=3306;server=localhost;uid=root;pwd=root"


#This is for server connectionstring
VB
con.ConnectionString = "Driver={MySQL ODBC 3.51 Driver};server=192.168.1.1;database=schemanetwork;uid=root;pwd=root;option=0" 
#My tables in schemalocal is the same value at schemanetwork

I want to get data from localhost then transfer to server network
basis query ->
SQL
Insert into schemanetwork.table1 select * from schemalocal;
Posted
Updated 1-Oct-14 1:09am
v3
Comments
RossMW 1-Oct-14 2:16am    
Depending on SQL version, have you looked at SSIS or older DTS?
Member 11088078 1-Oct-14 2:20am    
I want to apply it my application using vb.net, when I click the button my data in local host will transfer to my server network. Im doing this because our router is not consistent working. im using MySQL Administrator
RossMW 1-Oct-14 2:23am    
Unfortunately I'm on a silly iPad at the moment so can't write code at moment, but depending on the table you may just have to transverse the local table a row at a time and insert the data into the server table
Member 11088078 1-Oct-14 4:11am    
In my schemalocal I have table table1 and columns name, middle, lastname. Same as in schemanetwork. so that im using this query as basis --> Insert into schemanetwork.table1 select * from schemalocal
MohamedHassanAli 1-Oct-14 3:46am    
Have you tried Linked Servers ? i believe you can use it for your purpose. Check the link below.

http://msdn.microsoft.com/en-us/library/ms188279.aspx

VB
Dim LocalCN As New OdbcConnection("Driver={MySQL ODBC 3.51 Driver};database=schemalocal;option=0;port=3306;server=localhost;uid=root;pwd=root" )
Dim ServerCN As New OdbcConnection("Driver={MySQL ODBC 3.51 Driver};server=192.168.1.1;database=schemanetwork;uid=root;pwd=root;option=0")

'for get data from local
LocalCN.open()
Dim adp As New OdbcDataAdapter("SELECT * from schemanetwork.table1", LocalCN)
adp.Fill(dt)
LocalCN.close()

'for insert data to online server
ServerCN.open()

For i = 0 To dt.Rows.Count - 1

Dim cmd As New OdbcCommand("INSERT INTO schemanetwork.table1(a,b,c) values('" & dt.rows(i).item("a").tostring() &"','" & dt.rows(i).item("b").tostring() &"','" & dt.rows(i).item("c").tostring() &"')", ServerCN)
cmd.ExecuteNonQuery()


Next

ServerCN.close()
 
Share this answer
 
Comments
Member 11088078 2-Oct-14 23:14pm    
Finally done!, but one last question before i finish my question, what if I will add date range from column a because calumn a is date, i want to add in local connection, query like this "where a between 2014 and 2015"
Member 11088078 2-Oct-14 23:21pm    
Dim cmd As New OdbcCommand("INSERT INTO schemanetwork.table1(a,b,c) values('" & dt.rows(i).item("a").tostring() &"','" & dt.rows(i).item("b").tostring() &"','" & dt.rows(i).item("c").tostring() &"')where'" & dt.Rows(i).Item("a").ToString() & "' between '" & Trim(cmbfrom.Text.TrimEnd()) & "'And'" & Trim(cmbto.Text.TrimEnd()) & "'", ServerCN)


Im using this query but it is failed. can your correct it? this is my last problem please.
You can write your code like this :

VB
Dim LocalCN As New OdbcConnection("Driver={MySQL ODBC 3.51 Driver};database=schemalocal;option=0;port=3306;server=localhost;uid=root;pwd=root" )
Dim ServerCN As New OdbcConnection("Driver={MySQL ODBC 3.51 Driver};server=192.168.1.1;database=schemanetwork;uid=root;pwd=root;option=0")

'for get data from local
LocalCN.open()
Dim adp As New OdbcDataAdapter("SELECT * from schemanetwork.table1", LocalCN)
adp.Fill(dt)
LocalCN.close()


'for insert data to online server
ServerCN.open()
Dim cmd As New OdbcCommand("INSERT INTO schemanetwork.table1(a) values(" & dt.rows(0).item("a").tostring() &")", ServerCN)
cmd.ExecuteNonQuery()
ServerCN.close()
 
Share this answer
 
v5
Comments
Member 11088078 1-Oct-14 20:25pm    
Amazing, your correct, but I want to collect all the data, Your code is getting 1 row only and specific column. I want to get all data from local the transfer to network like doing this -->all(*)method, is that possible?
Member 11088078 1-Oct-14 21:48pm    
You are inserting on column a only, can you insert it to column a, b, c. Or in all the columns
[no name] 2-Oct-14 4:34am    
Please check bellow code :

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900