locked
Changed the OS and not able to run SQL now RRS feed

  • Question

  • User895691971 posted

    Hi, 

    I was using SQL Server before I upgraded my system to Windows 8. Now when I installed WebMatrix, I also Installed the SQL Server, but now I am getting error: 

    Cannot open database "StarterSite" requested by the login.

    I know there is something that I am missing, but what?

    Tuesday, September 3, 2013 11:57 AM

Answers

  • User-718146471 posted

    Adding a reference in WebMatrix is a little different.

    http://stackoverflow.com/questions/4697078/how-do-you-reference-third-party-assemblies-in-webmatrix

     

    Create a bin folder in your site and copy it to there. 
    WebMatrix doesn't provide a way to add references in the same way as VS.
    You need to add a using statement at the top of the CSHTML file:
    @using MyThirdParty.Component;
    

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 4, 2013 3:35 PM
  • User-718146471 posted

    From this article: http://www.microsoft.com/web/post/connecting-to-a-sql-server-or-mysql-database-in-webmatrix

     

    Making the Connection

    In order to connect to a SQL Server or MySQL database, you need the following:

    • A running instance of SQL Server 2005 or SQL Server 2008 (or the Express editions), or of MySQL versions 5 or 6. The database server can be installed on your computer or can be running on another computer.

    • The name of the database.

    • Credentials for the database. For SQL Server, this could either be the user you are logged in as (Windows authentication) or a database-specific user name and password (database authentication), depending on how the database is configured.

    To connect to the database, follow these steps:

    1. In WebMatrix, open the website you want to work with.

    2. Click the Databases workspace.

    ConnectingToSQLServerOrMySQLDatabase-1

    1. In the Database group of the ribbon, click New Connection. The Connect to a Database dialog box is displayed.

    ConnectingToSQLServerOrMySQLDatabase-2

    1. Give the connection a name. This can be anything, but it's helpful to use a name that identifies the database you're connecting to (for example, SalesDataConnection).

    2. Select the type of database you want to connect to (SQL Server or MySQL). Choose SQL Server if you're using either SQL Server or SQL Server Express.

    3. Fill in the remaining fields with the information for the database.

    4. If you want to add the database to your site, select Add to web.config. This applies to any type of site, including ASP.NET and PHP. Adding the database to the site makes it available for publishing later. When you add the database to your site, an entry for the database is put into the site's web.config file. (If you don't already have a web.config file, it's added automatically.)

    If you just want to connect to a database to make changes to it and you're not intending to publish the database with your site, leave this option unselected.

    If you're working with a SQL Server Express database, the completed dialog box will look similar to the following:

    ConnectingToSQLServerOrMySQLDatabase-3

    If you're working with a MySQL database, the dialog box might look like the following:

    ConnectingToSQLServerOrMySQLDatabase-4

    1. Click OK.

    If the connection is successful, you see the database in the Databases workspace just like you see databases that you create using SQL Server Compact:

    ConnectingToSQLServerOrMySQLDatabase-5

    (If you don't select the Add to web.config option, the database will show up under the Other Connections node.)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 4, 2013 3:41 PM
  • User-718146471 posted

    To make sure it works everywhere, you would want to use Database security (SQL Mixed Mode) since you can't count on the sql user being the same across different machines windows security. Usually, this is why they suggest using SQL CE for this stuff but you must need SQL Express. :-)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 5, 2013 9:18 AM
  • User-718146471 posted

    Appears there is a utility out there on code project that will do that: http://www.codeproject.com/Articles/25685/SQL-Server-to-SQL-Server-Compact-Edition-Database  You might have to do some extra stuff to make it fully functional. At least it's free.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 5, 2013 1:18 PM

All replies

  • User-718146471 posted

    I would try repair on SQL Server. Here is a thread that has some helpful tidbits too: http://forums.iis.net/t/1182269.aspx/1 

    Tuesday, September 3, 2013 12:04 PM
  • User895691971 posted

    Nah, its .NET Framework issue! I just installed win8 32 bit and I am not familiar with its apps and its already installed ones. WebMatrix is showing an error ".Net 2.0 is not installed". I am looking for a way to do that! 

    Tuesday, September 3, 2013 12:08 PM
  • User-718146471 posted

    Ah, ok. What you can do is download and install the .NET 2.0 redistributable. Do a quick google search for it, download it and install. :)

    Tuesday, September 3, 2013 12:14 PM
  • User895691971 posted

    O.o I have installed, the error is gone! But still the error is same :O Is this an SQL Error? Should I reinstall?

    Tuesday, September 3, 2013 12:25 PM
  • User-718146471 posted

    Try doing a repair of web matrix. Go to Start > Control Panel > Programs Find Web Matrix and do a repair.

    Tuesday, September 3, 2013 12:28 PM
  • User895691971 posted

    Tried but no success, the WebMatrix is loading the SQL CE files correctly, but its getting issues while loading the SQL Server files.

    Tuesday, September 3, 2013 12:36 PM
  • User895691971 posted

    On a related note, I think I have just lost all the credentials for logging in to the SQL server. And I am not able to get back to where I was. I have tried using SQL CE, it works. But SQL Server Database's dont. 

    My web.config is as:

    <add connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=StarterSite;User ID=sa;Password=blablabla" name="StarterSite" providerName="System.Data.SqlClient" />

    It was just in testing condition, So I didn't bothered changing name, or userid and used a stupid password. But I think I have lost the Authentication to it, it maybe was a Database or a windows one. I forgot! 

    Is there any way to get back to it? Or I need to create a new database now?

    If any options come up! Please tell me, can I get the data which was stored back? And also, what Authentication to use when upgrading to SQL Server, Database one or the Windows one? To make sure if anything happens I can re use the database.

    Tuesday, September 3, 2013 3:26 PM
  • User-718146471 posted

    I would repair the SQL Server at this point.

    Tuesday, September 3, 2013 3:38 PM
  • User895691971 posted

    I am not able to find that. Its just uninstall/Change

    Tuesday, September 3, 2013 3:52 PM
  • User-718146471 posted

    Oh, under Change, click Reinstall or Repair

    Tuesday, September 3, 2013 3:57 PM
  • User895691971 posted

    That's forcing me to find the folder, I have gone upto Microsoft SQL Server but no success, I don't know which folder to use.

    Tuesday, September 3, 2013 3:58 PM
  • User-718146471 posted

    Ok, lets try a different way, shall we? What I want you to do is install SQL Server Management Studio. This way you can get to touch the database server itself. Once you have SSMS installed, you connect to your local sql server and find out if you have a StarterSite database there. Are you using WebMatrix v2 or v3?

    Tuesday, September 3, 2013 4:07 PM
  • User-718146471 posted

    Also, do you happen to know if you have SQL Server 2008 installed? If so, to run on Win 8, you have to be running Sql Server Express 2008 SP3 or it will not run correctly.

    http://blogs.msdn.com/b/sqlexpress/archive/2012/03/02/sql-server-express-and-windows-8.aspx

    Tuesday, September 3, 2013 4:12 PM
  • User895691971 posted

    I am using v3 WebMatrix. And yes, sure I will try that out too! :)

    Tuesday, September 3, 2013 9:43 PM
  • User895691971 posted

    Oh this might be the issue, let me try!

    Tuesday, September 3, 2013 9:44 PM
  • User895691971 posted

    There is an option of this too, and I have this one and I am using this one.

    • SQL Server 2008 R2 Express SP1 and above. 
    Tuesday, September 3, 2013 9:53 PM
  • User-718146471 posted

    Ok, so you are using R2 express? Let me do a little digging on this side.

    Wednesday, September 4, 2013 9:32 AM
  • User-718146471 posted

    SQL Server 2008 R2 Express has a service pack 2, install that and give it a go. http://www.microsoft.com/en-us/download/details.aspx?id=30438

    Wednesday, September 4, 2013 9:33 AM
  • User895691971 posted

    I am using SQL Server 2008 Express SP2. From Web Platform Installer brother! 

    Wednesday, September 4, 2013 2:03 PM
  • User-718146471 posted

    Ah ok. I had another idea. Upgrade the SQL Express 2008 R2 to SQL Express 2012. I would suggest that you don't use web installer though.

    Wednesday, September 4, 2013 2:13 PM
  • User895691971 posted

    Can I get link for that?

    And also, can you please suggest me, what database to use so that it runs on all platforms. I guess for that only CE would work. 

    And yes, can I know whether I was facing authentication issues, or some SQL Server error? I am sure, it was SQL Server error. Because when I tried to create new Database it said: "Microsoft.SqlServer.Smo" not found or its dependencies not found. Something like that. Which meant some .dll is missing.

    Wednesday, September 4, 2013 3:12 PM
  • User-718146471 posted

    Ok, the link is http://www.microsoft.com/en-us/download/details.aspx?id=35579 

    As I understand it, WebMatrix can support MySQL, SQL Server Express, as well as Compact Edition.

    As far as the error, take a look at this link: http://stackoverflow.com/questions/1067818/application-cannot-find-microsoft-sqlserver-smo-on-sql-2008-machine

    Wednesday, September 4, 2013 3:20 PM
  • User895691971 posted

    But there, they are talking about "Add Reference" which is a feature in VS. How can I do that in WebMatrix? 

    You are right, WebMatrix supports these all, all we need is something like a plugin. MySql Connector, or something like that. I have tried, but why login error? Is there something like I am not having the database in the correct folder? 

    I will try out this Database. That you provided in the link :)

    Edit: Which files to download from that Download link?

    Wednesday, September 4, 2013 3:28 PM
  • User-718146471 posted

    Adding a reference in WebMatrix is a little different.

    http://stackoverflow.com/questions/4697078/how-do-you-reference-third-party-assemblies-in-webmatrix

     

    Create a bin folder in your site and copy it to there. 
    WebMatrix doesn't provide a way to add references in the same way as VS.
    You need to add a using statement at the top of the CSHTML file:
    @using MyThirdParty.Component;
    

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 4, 2013 3:35 PM
  • User-718146471 posted

    From this article: http://www.microsoft.com/web/post/connecting-to-a-sql-server-or-mysql-database-in-webmatrix

     

    Making the Connection

    In order to connect to a SQL Server or MySQL database, you need the following:

    • A running instance of SQL Server 2005 or SQL Server 2008 (or the Express editions), or of MySQL versions 5 or 6. The database server can be installed on your computer or can be running on another computer.

    • The name of the database.

    • Credentials for the database. For SQL Server, this could either be the user you are logged in as (Windows authentication) or a database-specific user name and password (database authentication), depending on how the database is configured.

    To connect to the database, follow these steps:

    1. In WebMatrix, open the website you want to work with.

    2. Click the Databases workspace.

    ConnectingToSQLServerOrMySQLDatabase-1

    1. In the Database group of the ribbon, click New Connection. The Connect to a Database dialog box is displayed.

    ConnectingToSQLServerOrMySQLDatabase-2

    1. Give the connection a name. This can be anything, but it's helpful to use a name that identifies the database you're connecting to (for example, SalesDataConnection).

    2. Select the type of database you want to connect to (SQL Server or MySQL). Choose SQL Server if you're using either SQL Server or SQL Server Express.

    3. Fill in the remaining fields with the information for the database.

    4. If you want to add the database to your site, select Add to web.config. This applies to any type of site, including ASP.NET and PHP. Adding the database to the site makes it available for publishing later. When you add the database to your site, an entry for the database is put into the site's web.config file. (If you don't already have a web.config file, it's added automatically.)

    If you just want to connect to a database to make changes to it and you're not intending to publish the database with your site, leave this option unselected.

    If you're working with a SQL Server Express database, the completed dialog box will look similar to the following:

    ConnectingToSQLServerOrMySQLDatabase-3

    If you're working with a MySQL database, the dialog box might look like the following:

    ConnectingToSQLServerOrMySQLDatabase-4

    1. Click OK.

    If the connection is successful, you see the database in the Databases workspace just like you see databases that you create using SQL Server Compact:

    ConnectingToSQLServerOrMySQLDatabase-5

    (If you don't select the Add to web.config option, the database will show up under the Other Connections node.)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 4, 2013 3:41 PM
  • User895691971 posted

    Yes, I have been using Helper is WebMatrix, some like

    @using Microsoft.System.Web;

    Some like that!

    I will try getting these assemblies.

    For your second reply. Does that mean that I will have to connect instead of using Database? I mean, I had the Database for this site. Shouldn't I be just using it like I did? Or do I need to connect it?

    Wednesday, September 4, 2013 3:49 PM
  • User-718146471 posted

    I would recommend doing a connection just to rule that out.

    Thursday, September 5, 2013 9:04 AM
  • User895691971 posted

    Oh, now I have tried to get back to where I was, in SQL CE! :(

    Help me in this: What type of authentication should I use, to make sure my Database would work anywhere where I would install SQL Server, is there any option whether in Windows or Database?

    Thursday, September 5, 2013 9:07 AM
  • User-718146471 posted

    To make sure it works everywhere, you would want to use Database security (SQL Mixed Mode) since you can't count on the sql user being the same across different machines windows security. Usually, this is why they suggest using SQL CE for this stuff but you must need SQL Express. :-)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 5, 2013 9:18 AM
  • User895691971 posted

    So that means, what ever you do, once you step in SQL Server Express, there is no turning back :D

    However, thanks alot for your help :) I really appreciate that! 

    Thursday, September 5, 2013 9:34 AM
  • User-718146471 posted

    Databases can be migrated to new formats however you would generally want to pick one and stick with it because they never go 100% easy or seamlessly. I've yet to see any data migration that didn't take some manual work at some point. They do have paid-for tools out there but who wants to pay $100s just for the ability to go back and forth. Also, those licenses may be single developer and not redistributable.

    Thursday, September 5, 2013 9:38 AM
  • User895691971 posted

    Databases can be migrated to new formats however you would generally want to pick one and stick with it because they never go 100% easy or seamlessly. I've yet to see any data migration that didn't take some manual work at some point. They do have paid-for tools out there but who wants to pay $100s just for the ability to go back and forth. Also, those licenses may be single developer and not redistributable.

    Did you mean .mdf --> .sdf and .sdf --> .mdf?

    Thursday, September 5, 2013 10:14 AM
  • User-718146471 posted

    Yes, but keep in mind you would need to ensure the security is set correctly for SQL Express would be one caveat. Another is any stored procs you have in SQL Express would no longer be an option in SQL CE. CE is very small, compact and isnt' designed for anything heavy duty. Any procs would need to be converted to standard SQL queries in your code so that could be a huge headache. While the moving of data would be supported, advanced features would not be in SQLCE.

    Thursday, September 5, 2013 10:21 AM
  • User895691971 posted

    Actually I don't have any Stored Procedures for my app. :D So that aint a headache. 

    However, how to shift from .sdf to .mdf?

    Thursday, September 5, 2013 10:24 AM
  • Thursday, September 5, 2013 10:49 AM
  • User895691971 posted

    No no sorry, that's for SQL CE --> SQL Server 2008. I wanted to know to get down from SQL Server to SQL CE

    Thursday, September 5, 2013 1:05 PM
  • User-718146471 posted

    Appears there is a utility out there on code project that will do that: http://www.codeproject.com/Articles/25685/SQL-Server-to-SQL-Server-Compact-Edition-Database  You might have to do some extra stuff to make it fully functional. At least it's free.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 5, 2013 1:18 PM