Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi,
am updating local machine database by using con method in .net..
now i want to update server side database(same table in local machine) by using same program..
i know the server database username,database name,password,table name ..
please anyone help me regarding this....and give me the syntax...
Posted
Comments
ZurdoDev 21-Nov-13 8:27am    
What is the con method? Where are you stuck?

Perhaps, http://www.connectionstrings.com/, is what you are asking about.
Kumar Kovuru 21-Nov-13 8:33am    
SqlConnection conn = new SqlConnection("user Id=xxxx; Password=yyyy; server=.\\SqlExpress; Database=zzzz;");
this is my local machine connection then how can i update server database details here...

What is "con method"?? I've never heard of it.

In any case, it's a simple matter of changing your connection string. You can find a ton of examples and connection string formats at http://www.connectionstrings.com/[^]. All you need to know is what kind of database engine you're connecting to and which technology you're using to connect.
 
Share this answer
 
Hi Kumar,

If you want to update server database, then you need to use server side database in connection string like this
C#
SqlConnection conn = new SqlConnection("user Id=rk.prabakar; Password=rk.prabakar; server=192.168.1.XX\SQL2008R2; Database=TestDatabase;");


Replace the server name with your actual server name that you intend to update.
Server SQL instance name may be like 192.XX.XX.XXX/SQLServer (comes with ip address and sql instance name)
Change userid and password with your username and password that is used to connect remote database

Hope this helps you a bit.

Regards,
RK
 
Share this answer
 
v3
Comments
Kumar Kovuru 22-Nov-13 2:30am    
Sorry Rk, It is not Working..........Please Help Me..
♥…ЯҠ…♥ 22-Nov-13 2:37am    
you got any error?
Kumar Kovuru 22-Nov-13 2:42am    
yes..
SqlConnection conn = new SqlConnection("user Id=aaa; Password=********; server=abc.de.fgh.ij/SqlExpress; Database=xyz;");
But am getting like this...
Error:A 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
♥…ЯҠ…♥ 22-Nov-13 2:44am    
Ok I think you need to enable remote access to the database in server machine.... refer this http://www.codeproject.com/Answers/686079/A-network-related-or-instance-specific-error-occur#answer1
Kumar Kovuru 22-Nov-13 3:44am    
i did it but am getting same error...
C#
SqlConnection conn = new SqlConnection("user Id=aaa; Password=********; server=abc.de.fgh.ij/SqlExpress; Database=xyz;");

is wrong.

Better:
C#
SqlConnection conn = new SqlConnection("user Id=aaa; Password=********; server=abc.de.fgh.ij\\SqlExpress; Database=xyz;");

OR
C#
SqlConnection conn = new SqlConnection(@"user Id=aaa; Password=********; server=abc.de.fgh.ij\SqlExpress; Database=xyz;");
 
Share this answer
 
Comments
Kumar Kovuru 29-Nov-13 8:04am    
Hi Phil.o,
i was tried with the first one of yours...
have a look on this code..
-------------------------------------
SqlDataAdapter sda = new SqlDataAdapter("select * from Product", conn);
DataSet ds = new DataSet();
sda.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
----------------------------------------
am getting error on third line i.,e " sda.Fill(ds);".
Error:A 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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Please have a look on it..
phil.o 29-Nov-13 8:08am    
If you have another problem, then post a new question, and people will try to help based on their own available time.
If this is still related to the same problem, then improve your question instead of using comments.
Kumar Kovuru 29-Nov-13 8:15am    
Sure next time i will do like that,,,please help me regarding this...
phil.o 29-Nov-13 8:27am    
Then I may try to help, next time :)
Kumar Kovuru 29-Nov-13 8:34am    
Phil.o, Please... :)

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