Last post Aug 07, 2015 02:51 AM by wmec
Aug 05, 2015 08:44 AM|bonitasg|LINK
I'm newbie in ASP. NET so ..
Anyway, to the point. I inherit an ASP. NET application from a previous guy. Originally the app use SQL Express 2008 and the connection string in web.config is:
<add connectionString="Provider=SQLOLEDB.1;Password=AdminPass;Persist Security Info=True;User ID=sa;Initial Catalog=hotel;Data Source=.\SQLEXPRESS" name="database" providerName="System.Data.SqlClient" />
Now i moved the app to another server running SQL 2012 (full) and the SQL server name is now called SQLSERVER, i restore the hotel database onto SQLServer and the only thing i changed in the web.config is replacing .\SQLEXPRESS by SQLServer. However the
app cannot connect to the database. Can anyone please tell me why ?
Aug 05, 2015 09:02 AM|Careed|LINK
Try this for your connection string:
connectionString="Data Source=.\SQLSERVER;Initial Catalog=hotel;Integrated Security=True;"
Aug 05, 2015 12:42 PM|bonitasg|LINK
just that ? do i need to add the sql user and password ? thanks
Aug 05, 2015 01:19 PM|Careed|LINK
It is usually best not to use a user name and password on your production server. Of course, if it doesn't work with integrated security, you will need to either add NETWORK SERVICE (the default user for ASP.NET) to your SQL Server as a user or use an existing
user name and password, noting that if you don't use encryption on your web.config, everyone with direct access to the server will know your password (as we now know if it for your SQLEXPRESS instance).
Aug 05, 2015 01:33 PM|bonitasg|LINK
i just tried .\SERVERNAME
it didn't work.
i saw the old SQLEXPRESS 2008 server. the server is named .\SQLEXPRESS
Aug 05, 2015 04:22 PM|jkjhse|LINK
You can encrypt the connection string part if you include database password.
Why dont you use the ip address of the server instead of .SqlServer. It worked for me
<add connectionString="data source=192.168.1.12;database=mydbname; Uid=sa;Pwd=123345456" name="dname" providerName="System.Data.SqlClient" />
Aug 06, 2015 02:56 AM|bonitasg|LINK
i tried the IP as well.. same old error from the ASP.NET app : could not connect to database
Aug 06, 2015 03:02 AM|jkjhse|LINK
Can you connect to the database in Visual Studio? If yes, In Server Explorer Click on the Database name with the node open. In the properties section below that,( You can see that by right clicking on the database name and selecting properties too)
See the option "ConnectionString"
Try that string in your Web.Config.
First of all post your new connection string minus the password here.. I think you are using the wrong provider.
Aug 06, 2015 03:53 AM|bonitasg|LINK
i can connect to the SQL server from VS. However when i connect to the "hotel" app database and expand it, i got a message saying this project only support up to SQL 2008. I think it could be a potential problem here as im running sql 2012 on this server.
anyway this is my connection string obtained from VS:
Data Source=SQL-SVR;Initial Catalog=hotel;Integrated Security=True
tried it and it doesnt work.
Aug 06, 2015 09:23 AM|jkjhse|LINK
Post your full connection string block. And Also request moderator to move this thread to correct category. maybe you will receive better support there.
Aug 06, 2015 10:29 AM|bonitasg|LINK
that is the full connection string i copy from VS.
Aug 06, 2015 11:30 AM|bonitasg|LINK
I got it working now !!
The problem was that the previous guy used 'sa' account to authenticate in the app's connection string in mixed mode. In my new server, SQL was installed using Windows Authentication mode, not mixed mode. so when I tried login with 'sa' account, i got the
error 233 "login successful but ... name pipe" blah blah. I could not use the 'sa' account.
so i reinstalled SQL 2012 with mixed mode and it's working now, thanks all for your kind help.
One more question: i have the app source code, how can I re-create the project and keep working on it in VS ? i don't have the project file ...
Aug 07, 2015 02:51 AM|wmec|LINK
Try to put this
<add name="conn2" connectionString="Data Source=192.?.?.?\your_db_instance;Initial Catalog=your_db_schema;Integrated Security=False;User ID=your_db_login;Password=??????" providerName="System.Data.SqlClient"/>
within Web.config/app.config file in your project, to ensure the project will work fine with the database.