Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Developers:
How can i save data from C# window application to the remote SQL Server with SQL server Authentication?

actually i am developing an application, in which i need to save the product transaction to the computer which is remote not local, can anyone when tell me how can i access remote computer and save data there...?
Posted

Firstly, Solution 1 is OK. Apart from that Check by pinging the Server once. Also, before writing Connection String use @ (Verbatim)
 
Share this answer
 
Comments
Sander Rossel 30-Oct-11 14:40pm    
Pinging the server isn't necessary I think. Connection.Open will simply throw an Exception if it can't login (or timeouts, a few seconds wait I guess). Catch the Exception and handle it.
@ would be necessary in my example yes. Didn't think of it as a VB programmer.
My 5 for the additions though :)
In exactly the same way as you would normally do. Except your connectionstring would use the server name or IP. For example: "Data Source=1.2.3.45\MyCompany;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;"
You should make sure the server allows remote connections though.
 
Share this answer
 
Comments
Hammad Rasheed 30-Oct-11 13:38pm    
Thanks alot dear, i have posted an other question please have a look on that question too.
Hammad Rasheed 30-Oct-11 13:45pm    
i have another question,


Can i use any variable in which IP Address or server name is saved, for example i have save IP Address in variable "IPAddress" and place in the server path as given below...!

"Data Source=IPAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;"
Sander Rossel 30-Oct-11 14:43pm    
That would work as any other string concatention...
String connString = @"Data Source=" + IPAddress + ";Initial..."
Or use String.Format as an alternative.
Hammad Rasheed 31-Oct-11 0:52am    
Thanks alot for your helps boys...!

"string strFile = "D\\WORKS\\MyData.mdb";
string strPass ="MDBPassword";

string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strFile + ";Jet OLEDB:Database Password=" + strPass + ";";"

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