locked
about connection string RRS feed

  • Question

  • I'm doing a silverlight project connected to .mdf database.
    While debugging my project, it works fine.
     But when i deploy my project in ISS server n try to run my project ,it say remote server not access....

    I have window authentication to connect with my .mdf database...

    N i found that at deploy time it required sql server authentication.

    So i install SQL server management and make a sql server authnetication  username and password...then attach my previous .mdf database ....now i want to use newly generated connection string...but could figure out connection string....

    my original connection string which is not access during deployment run on localhost....

    <connectionStrings>

            <add name="majorDBEntities1" connectionString="metadata=res://*/majorModel.csdl|res://*/majorModel.ssdl|res://*/majorModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\majorDB.mdf;Integrated Security=False;Connect Timeout=30;User Instance=False;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />

      </connectionStrings> 


    sameer
    Wednesday, October 26, 2011 12:30 PM

Answers

  • thank for reply once more...well i create sql script of my .mdf database and then create a .dbo file and attach it in my ssms within sql authentication databases section...previous error doesn't occur now .

    When i run my project in development server it work fine...but when i run it in iis server after deploy it....


    I got this error ....once more I'm using  data entity model,wcf ria , silverlight 4 and project done in VS 2010..and SSMS 2008 to host my databse ,,,my IIS is of version 5.1   and OS is Window xp professional version 2002 sp 3   .....


    sameer

    Hi sameer,

    What’s your current connection string now? From your description, I think the current connection string should looks like:

    Data Source=.\SQLEXPRESS;Database= majorDB;User ID=myUsername;Password=myPassword; Integrated Security=False;

    right?

    Based on the error message you got, it seems that your application cannot find the specified SQL Server instance. After deploying the application, did you attach the database and modify the connection string to point to the SQL Server instance running on the server?

    Which version and edition of SQL Server do you have on the server? Is it a default or named instance? If it’s a default SQL Server instance, please change the connection string to:

    Data Source=.;Database= majorDB;User ID=myUsername;Password=myPassword; Integrated Security=False;

    If it’s named instance, please first check the instance name and change the connection string to:

    Data Source=.\InstanceName;Database= majorDB;User ID=myUsername;Password=myPassword; Integrated Security=False;


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Get or Request Code Sample from Microsoft
    If you have any feedback, please tell us.
    • Proposed as answer by Papy Normand Thursday, November 3, 2011 11:41 AM
    • Marked as answer by KJian_ Friday, November 4, 2011 5:43 AM
    Wednesday, November 2, 2011 6:37 AM

All replies

  • Hi,

    You have to set your system IP Address to DataSource

    eg:Data Source=192.002.1.1

     

    <connectionStrings>

            <add name="majorDBEntities1" connectionString="metadata=res://*/majorModel.csdl|res://*/majorModel.ssdl|res://*/majorModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;

    Data Source=192.002.1.1;AttachDbFilename=|DataDirectory|\majorDB.mdf;Integrated Security=False;Connect Timeout=30;User Instance=False;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />

      </connectionStrings> 

    for more information check the below link

    http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/33d297f0-ebd5-4a76-8691-3e764fe0bf19/#75b35958-75b8-4d38-8909-5ac0e68e7b17


    PS.Shakeer Hussain
    Wednesday, October 26, 2011 1:53 PM
  • Hello,

    I suppose that you have used a Visual Studio Express Edition to create your application but this kind of edition is unable to build a correct connection string ( a problem of understanding between the Visual Studio Team and the SQL Server Express Team ).

    I would suggest you to read this thread done by Mike Wachal ( who was the reference on the forums for any problem about SQL servre Express ) :

    http://social.msdn.microsoft.com/Forums/en-US/sqlexpress/thread/a0ed5d30-63b0-4acd-b807-20a4d2d2a583

    You have explanations and links explaining how to install correctly a SQL Server instance for Web use.

    You will find the link towards the SQL Server Express Team Blog which is the main source for any informations and problems related to SQL Server Express.

    A little remark : you have User Instance = False ( proof that you used a VS Express ).AttachDbFileName should used only for connection to user instance

    Please, could you have a look at this link ?

    http://social.msdn.microsoft.com/Search/en-US/sqlserver?query=%7cDataDirectory%7c&rq=meta:Search.MSForums.ForumID(4dfc1132-ed0e-4490-865b-89dcc2402af9)+site:microsoft.com&rn=SQL+Server+Express+Forum

    it contains a sum of link about |DataDirectory| and the 7th link gives an explanation how to use correctly |DataDirectory|

    According to me, i would replace the AttachDataFileName part by Initial Catalog = <YourDatabaseName> which has the advantage to be used versus any SQL Server edition ( user instance can be used only with SQL Server Express Edition ). Moreover SQL Server 2012 (Denali ) will be the last version which is supporting user instances.

    A moderator may move this thread towards the SQL Server Express Forum where, since 2005 , most of threads related to this kind of problem are posted or moved. I have not done the move only because i prefer to do the move after having received the agreement of the original poster.

    Don't hesitate to post again for more help or explainations.

    Have a nice day

    PS : with user instance = true, you cannot use the SQL Server authentification, nor to have a remote connection.Mike Wachal has explained how to do a backup/restore of your database ( not easy ).Don't forget to set the AutoClose and AutoShrink properties to false ( if you don't want to have performances problems ). It is better to set ConnectionTimeout to 60 seconds for a Web database if you want to avoid timeouts during the connection.Idem for CommandTimeout property ( especially if the database is heavily used ).Check also the growth size of the datafile and logfile which are set to the minimum ( too small very often ).The growth of a datafile/logfile is a lengthy Windows operation needing many resources with possible timeout during the execution of your Command


    Mark Post as helpful if it provides any help.Otherwise,leave it as it is.
    Wednesday, October 26, 2011 3:08 PM
  • my original connection string was above mention with user  instance = true and also integrated security = true ...it work fine when in debug my program bt ....it say remote server not access...when publish....
    sameer
    Friday, October 28, 2011 5:15 AM
  • Hello,

    Please, could you post the exact and full error message ?

    Without this error message, we are unable to help you more efficiently.

    Please, could you check whether the SQL Server instance is configured to accept remote connections.If your SQL Serverver instance does not accept the remote connections, you have to enable this property

    Open your SQL Server Management Studuio.

    Connect to your instance

    right-click on the name of your instance select Properties

    in the new form select the Connections page in the right part go to the bottom and look at Authorizes the remote connections to this server ( as i have a french SSMS, it is only a translation to english, but i have problems with my english )

    Please, could you tell us if the computer where the SQL Server is installed is the same one where the application is running ?

    We are waiting for your feedback to try to help you more efficiently

    Have a nice day

    PS : instead of using AttachDbFileName ( reserved to user instance ) , i would suggest you Initial Catalog = majorDB ( that's the name of the database , i found this name from the name of the datafile name that's to say majorDB.mdf ). The SQL Server knows the datafile name as you provide the name of the database, it is shorter, surer and you have less risks of misspelling the full name of the datafile )


    Mark Post as helpful if it provides any help.Otherwise,leave it as it is.
    • Edited by Papy Normand Friday, October 28, 2011 9:07 PM PS added
    Friday, October 28, 2011 8:59 PM
  • thank for reply once more...well i create sql script of my .mdf database and then create a .dbo file and attach it in my ssms within sql authentication databases section...previous error doesn't occur now .

    When i run my project in development server it work fine...but when i run it in iis server after deploy it....


    I got this error ....once more I'm using  data entity model,wcf ria , silverlight 4 and project done in VS 2010..and SSMS 2008 to host my databse ,,,my IIS is of version 5.1   and OS is Window xp professional version 2002 sp 3   .....


    sameer
    Tuesday, November 1, 2011 5:07 AM

  • sameer
    Tuesday, November 1, 2011 5:38 AM
  • thank for reply once more...well i create sql script of my .mdf database and then create a .dbo file and attach it in my ssms within sql authentication databases section...previous error doesn't occur now .

    When i run my project in development server it work fine...but when i run it in iis server after deploy it....


    I got this error ....once more I'm using  data entity model,wcf ria , silverlight 4 and project done in VS 2010..and SSMS 2008 to host my databse ,,,my IIS is of version 5.1   and OS is Window xp professional version 2002 sp 3   .....


    sameer

    Hi sameer,

    What’s your current connection string now? From your description, I think the current connection string should looks like:

    Data Source=.\SQLEXPRESS;Database= majorDB;User ID=myUsername;Password=myPassword; Integrated Security=False;

    right?

    Based on the error message you got, it seems that your application cannot find the specified SQL Server instance. After deploying the application, did you attach the database and modify the connection string to point to the SQL Server instance running on the server?

    Which version and edition of SQL Server do you have on the server? Is it a default or named instance? If it’s a default SQL Server instance, please change the connection string to:

    Data Source=.;Database= majorDB;User ID=myUsername;Password=myPassword; Integrated Security=False;

    If it’s named instance, please first check the instance name and change the connection string to:

    Data Source=.\InstanceName;Database= majorDB;User ID=myUsername;Password=myPassword; Integrated Security=False;


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Get or Request Code Sample from Microsoft
    If you have any feedback, please tell us.
    • Proposed as answer by Papy Normand Thursday, November 3, 2011 11:41 AM
    • Marked as answer by KJian_ Friday, November 4, 2011 5:43 AM
    Wednesday, November 2, 2011 6:37 AM