Thursday, March 19, 2015

Connecting FHV Website to SQL Server

On 3/16 or so, I found that I could no longer attach my FHV web project to SQL Server. I tried many things, but ended up uninstalling ALL SQL server stuff and re-installing SqlServer 2012 with Advanced Services. I had saved the old FHV database (from C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\DATA). I had not saved the scripts to create the tables, though I do have the data in CSV format.

So, now with a new empty, SQL Server, I create a DB named  FHV. Next I create a user named Fhv_Web_User with password from Web.Config file. User mapping to FHV with db datareader and db datawriter.

Next, can I reboot and still start the database? Yes I could and the DB started automatically. I then stopped it (SQL Configuration Manager) and copied the databases from the DATA folder to D:\SQL Server Stuff After Fresh Install. Then I copied the old FHV files back to the DATA folder and restarted SQL Server and voila. I had the database with all the tables and contents.I then copied the old FHV.mdf to the new backup folder and deleted the old backup folder.

BUT - Fhv_Web_User could not connect - not even with Management Studio. Nor could I modify the properties. So I created Fhv_WebUser2 and this time I specified [dbo] as the Default Schema and I could then connect and the web site started working.