Click here to Skip to main content
15,891,758 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi i have asp source code and it has a data base to store data(i use sql server express 2008), it works perfectly in my local computer
i use this method to create my connection string:
C#
SqlConnection con = new SqlConnection("Data Source=ARASH-PC;Initial Catalog=Ranker;Integrated Security=True;Pooling=False");
con.Open();
...


i uploaded my source code to my server and now it's time to give a new connection string because i want my ASP site use sql server on my VPS.but i don't know the connection string on my server!my computer name on VPS is VM so i used :

C#
SqlConnection("Data Source=VM;Initial Catalog=Ranker;Integrated Security=True;Pooling=False");


and uploaded the source to server but it still can't open connection and makes an exception!
on my computer i use server explorer in VS2010 to find connection string but on my server i don't have visual studio!i know my question is a basic and rookie question but this is the first time i try to upload my source code on a VPS
What's my mistake ? how should i find connection string
sorry for long post
Posted
Updated 17-Sep-12 6:31am
v2
Comments
[no name] 17-Sep-12 12:31pm    
Try using the IP address of the SQL server instead of "VM".
Arash Khangaldi 17-Sep-12 12:50pm    
it seems correct!should i make any change in my web.config file then?

If your database is on VPS (server), you need to connnect with this computer, not with VM (local machine)!
C#
SqlConnection("Data Source=VPS;Initial Catalog=Ranker;Integrated Security=True;Pooling=False");

As Was Aday wrote, try to use ip, instead of server name.
 
Share this answer
 
Comments
Arash Khangaldi 17-Sep-12 14:27pm    
i updated my connection string to this:
SqlConnection("Data Source=209.54.48.113;User ID=****;password=****;Initial Catalog=database;Trusted_Connection=True;Pooling=False");
but still not working!
Maciej Los 17-Sep-12 15:17pm    
What you mean "not working"? What kind of error do you have?
Have you seen this: Configure SQL Server to allow remote connections?
see all types of connection string here http://www.connectionstrings.com/[^]

i hope it helps you
 
Share this answer
 
v2

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