dimanche 12 juin 2016

Sql database to another pc-sql database

i'm using this code:

SqlCommand cmd = new SqlCommand(" MERGE customermaster AS target USING Tamio.dbo.memberform AS source ON target.id = source.id WHEN MATCHED THEN UPDATE SET target.name = source.name WHEN NOT MATCHED THEN INSERT (id, name) VALUES (source.id, source.name);", con);

I want to choose from my local database.

I try this but it says incorrect syntax

SqlCommand cmd = new SqlCommand(" MERGE customermaster AS target USING [local]Tamio.dbo.memberform AS source ON target.id = source.id WHEN MATCHED THEN UPDATE SET target.name = source.name WHEN NOT MATCHED THEN INSERT (id, name) VALUES (source.id, source.name);", con);

Also this is my local connection

SqlConnection con = new SqlConnection(@"Data Source=(local);Initial Catalog=Tamio;Integrated Security=True");

and this is my client pc connection

SqlConnection conn = new SqlConnection(@"Data Source=192.168.1.101;Initial Catalog=Imatismos;user ID=admin;Password=1234");

Aucun commentaire:

Enregistrer un commentaire