Search code examples
sql-server-2008-express

What mstrConnection should I use on a webpage to access local SQL Server Express (localhost\SQLEXPRESS)?


Would the following suffice?

Dim mstrConnection As String =
  "workstation id=COMPUTER;packet size=4096;data source=localhost\SQLEXPRESS;
    integrated security=false;user id=x309-PC\x309;password=abc"

Solution

  • You should be able to get away with a simpler connection string like the following:

    Data Source=(local)\SQLExpress;Initial Catalog=myDatabaseName;User ID=myUsername;Password=myPassword;

    You also need to make sure in the SQL server security logins you have both mapped the user to a SQL login as well as given the user rights to the database you are interacting with. You can download MS SQL management studio express 2008 to view and set these settings.