using SQL 2008; connectionString; please help

Last post 03-22-2009 11:55 PM by kenbati. 30 replies.

Sort Posts:

  • using SQL 2008; connectionString; please help

    02-16-2009, 10:52 PM
    • Member
      234 point Member
    • kenbati
    • Member since 01-29-2007, 7:54 PM
    • Posts 402

    string connectionString = "Driver={SQL Native Client};Server=.\\SQLExpress; AttachDbFilename=|DataDirectory|AceSA.mdf;Database=dbname;Trusted_Connection=Yes";

     

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.ArgumentException: Keyword not supported: 'driver'.

    Do not forget to mark it as answer!!

    Our economy is bad due to corruption and monoply!
  • Re: using SQL 2008; connectionString; please help

    02-16-2009, 11:20 PM
    • Participant
      1,451 point Participant
    • manojlev
    • Member since 09-08-2008, 6:43 AM
    • Mumbai
    • Posts 277

    Hi kenbati,

         Use your connection string as follows:

        Data Source=name of datasource  ;Initial Catalog= give catalog ;Persist Security Info=True;User ID=admin;Password=pass

     

    Thank You
    Manoj Chavan
    -------------------------------------------
    Web Application Developer(C#.NET, ASP.NET, C++.NET)
    My Blog
    My Site
    Mauli softwares
    Always think high, Always Dream High.
    If this post helps you then plz Mark It as Answer
  • Re: using SQL 2008; connectionString; please help

    02-16-2009, 11:21 PM
    • Star
      12,926 point Star
    • Kumar Reddi
    • Member since 11-11-2004, 9:54 PM
    • Virginia
    • Posts 2,378

     I dont think you need to use the SQL Native client driver portion at all..

    Here is the typical connection string when using the .mdf file

    string connectionString = "Server=.\SQLExpress;AttachDbFilename=c:\mydbfile.mdf;Database=dbname; Trusted_Connection=Yes;"
     
    Also some explanation about native client

     Also look at the ww.connectionstring.com website for syntax regarding various database connection stringss

    Kumar Reddi
  • Re: using SQL 2008; connectionString; please help

    02-17-2009, 12:14 AM
    • Member
      234 point Member
    • kenbati
    • Member since 01-29-2007, 7:54 PM
    • Posts 402

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Data.SqlClient.SqlException: Unable to open the physical file "C:\AceSA\App_Data\AceSA.mdf". Operating system error 5: "5(Access is denied.)".
    Cannot attach the file 'C:\AceSA\App_Data\AceSA.mdf' as database 'dbname'.

    still getting an error. please help. thanks

    Do not forget to mark it as answer!!

    Our economy is bad due to corruption and monoply!
  • Re: using SQL 2008; connectionString; please help

    02-17-2009, 12:21 AM
    • Contributor
      2,360 point Contributor
    • vipuldonga
    • Member since 02-10-2009, 11:18 AM
    • Ahmedabad
    • Posts 418

     Hi,

    i think you can't connect .mdf file in your project

    for more information you can refer this link

    http://forums.asp.net/t/857047.aspx

    Thanks & Regards
    Vipul Donga

    Mark it as an answer, if it helped

    if (MyAnswer)
    MarkAsAnswer();
  • Re: using SQL 2008; connectionString; please help

    02-17-2009, 12:33 AM
    • Member
      234 point Member
    • kenbati
    • Member since 01-29-2007, 7:54 PM
    • Posts 402

    what? This do not make sense.

    Do not forget to mark it as answer!!

    Our economy is bad due to corruption and monoply!
  • Re: using SQL 2008; connectionString; please help

    02-17-2009, 7:21 PM
    • Member
      234 point Member
    • kenbati
    • Member since 01-29-2007, 7:54 PM
    • Posts 402

    How would one point to different mdf databases?

    Do not forget to mark it as answer!!

    Our economy is bad due to corruption and monoply!
  • Re: using SQL 2008; connectionString; please help

    02-17-2009, 9:17 PM
    • Star
      12,926 point Star
    • Kumar Reddi
    • Member since 11-11-2004, 9:54 PM
    • Virginia
    • Posts 2,378

    kenbati:


    Cannot attach the file 'C:\AceSA\App_Data\AceSA.mdf' as database 'dbname'.

     

    Are you sure the name of the database is "dbname" in the mdf file

    Kumar Reddi
  • Re: using SQL 2008; connectionString; please help

    02-18-2009, 11:51 PM
    • Member
      234 point Member
    • kenbati
    • Member since 01-29-2007, 7:54 PM
    • Posts 402

     

    All I want is to connect to my sqlexpress database. In my module I must use the connectstring. thanks

    'C:\AceSA\App_Data\AceSA.mdf'

    Do not forget to mark it as answer!!

    Our economy is bad due to corruption and monoply!
  • Re: using SQL 2008; connectionString; please help

    02-19-2009, 7:29 AM

    Hi,

    If we would like to connect to database files in App_Data with SQL Server Express user instance, the connection string should look like: 

    connectionString="Data Source=.\SQLEXPRESS; AttachDbFilename=|DataDirectory|\NORTHWIND.mdf; Integrated Security=True; User Instance=True"

    User instance is only supported by SQL Server Express Edition. A SQL Server user instance is similar to a normal SQL Server instance but it is created on demand while normal instances are created during setup.

    For more information, please refer to the documentations below:

    SQL Server 2005 Express Edition User Instances
    http://msdn.microsoft.com/en-us/library/bb264564.aspx

    Working with User Instances 
    http://msdn.microsoft.com/en-us/library/ms254504(VS.85).aspx

    Jian Kang
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Re: using SQL 2008; connectionString; please help

    02-19-2009, 10:15 AM
    • Member
      234 point Member
    • kenbati
    • Member since 01-29-2007, 7:54 PM
    • Posts 402

     

    string connectionString = "Server=.\\SQLExpress; AttachDbFilename=|DataDirectory|AceSA.mdf; Integrated Security=True; Trusted_Connection=Yes";

     

    Unable to open the physical file "C:\AceSA\App_Data\AceSA.mdf". Operating system error 5: "5(Access is denied.)".
    An attempt to attach an auto-named database for file C:\AceSA\App_Data\AceSA.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

    Do not forget to mark it as answer!!

    Our economy is bad due to corruption and monoply!
  • Re: using SQL 2008; connectionString; please help

    02-19-2009, 9:38 PM
    Answer

    Please right-click the folder “C:\AceSA\App_Data\” which contains the database files, open “Property | Security”. Then add ASPNET (or "NetworkService” account, for an application that runs on IIS 6.0) and grant it full access to the folder and all files inside.

    For some reasons, we might need to add “SYSTEM” and “ASPNET” account as well under some circumstances.

    Based on your current connection string, I think the you would like to attach the database is to SQL Server Express instance not SQL Server Express user instance.

    If we don’t work with user instance, the database will be attached in SQL Server instance until we detached it manually. We can find it in SQL Server Management Studio.

    Please open SQL Server Management Studio Express, connect to the SQL Server Express instance “.\SQLEXPRESS” and check if you can see the database. If you can see it, which means the database has been attached to your SQL Server Express instance and we can modify the connection string as below: 

    <add name="testConnectionString" connectionString="Data Source=.\sqlexpress;Initial Catalog=test;Integrated Security=True"  providerName="System.Data.SqlClient" />

    Jian Kang
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Re: using SQL 2008; connectionString; please help

    02-20-2009, 12:17 AM
    • Member
      234 point Member
    • kenbati
    • Member since 01-29-2007, 7:54 PM
    • Posts 402

    thanks for the detail info. u r great.

     

    Why ms makes simple things so complex?  I am sure millions of poeple must have stumbled over this issue.

    Do not forget to mark it as answer!!

    Our economy is bad due to corruption and monoply!
  • Re: using SQL 2008; connectionString; please help

    02-21-2009, 12:40 AM
    • Member
      234 point Member
    • kenbati
    • Member since 01-29-2007, 7:54 PM
    • Posts 402

    How would I convince the service provider to do this on the public server?

    Could there be any other way?

    I tried the following and it worked to some extent - please help - thanks

    SqlConnection xconnectionString = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString());

    Do not forget to mark it as answer!!

    Our economy is bad due to corruption and monoply!
  • Re: using SQL 2008; connectionString; please help

    02-21-2009, 1:26 AM

    kenbati:

    How would I convince the service provider to do this on the public server?

    Could there be any other way?

    I tried the following and it worked to some extent - please help - thanks SqlConnection xconnectionString = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString());

    On the web server, I think you can attach the database in SSMS and connect to it with the following connectiong string:

    <add name="testConnectionString" connectionString="Data Source=localhost;Initial Catalog=DataBaseName;User Id=UserName;Password=UserPassword;"
       providerName="System.Data.SqlClient" />
    

    Generally, the login account name and password should be provided by your host provider. I would suggest you contact the host provider for more inforamtion. 

    Jian Kang
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Page 1 of 3 (31 items) 1 2 3 Next >