help i am a noob connectionstring

Apr 27, 2009 at 4:19 PM
Edited Apr 27, 2009 at 4:25 PM
hi it may be easy for you and everyone else to edit a connection string but i cannot what and how do it need to edit from this

    <appSettings/>
    <connectionStrings>
        <add name="SlickTicket" connectionString="
                  Data Source=.\SQLEXPRESS;                                  
                  Initial Catalog=SlickTicket;
                  Integrated Security=True"
                  providerName="System.Data.SqlClient"/>
    </connectionStrings>
    <system.web>


  I created a datebase it called SlickTicket

when i do the set up i get to

Database Creation

page i get this message in red at the botom

what do i need to chage in the connection string

please could someone write a connection string that works and infromation you need to make a connection string i will tell you just ask but at noob level!!!

thanks alot


An error occured: System.Data.SqlClient.SqlException: Cannot open database "SlickTicket" requested by the login. The login failed. Login failed for user 'MOTTERS\Stephen Mottley'. at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.SqlClient.SqlConnection.Open() at setup_build_database.btnRunSQL_Click(Object sender, EventArgs e) in c:\Documents and Settings\Stephen Mottley\Desktop\Slick-Ticket v1.05\setup\build_database.aspx.cs:line 44


Apr 27, 2009 at 9:18 PM
I need connection help as well.  I am trying to login with a username and password.  Here is what I am using(my server and user information changed for privacy of course)

    <connectionStrings>

        <add name="SlickTicket" connectionString="
                  Data Source=myservername;                                  
                  Initial Catalog=SlickTicket;
                  User ID=sa;
                  Password=sa-password"
                  providerName="System.Data.SqlClient"/>
    </connectionStrings>

Error I get:

An error occured: System.Data.SqlClient.SqlException: Line 8: Incorrect syntax near '('. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at setup_build_database.btnRunSQL_Click(Object sender, EventArgs e) in e:\Websites\Inetpub\wwwroot\intranet\ticket\setup\build_database.aspx.cs:line 66

Any help?

Coordinator
Apr 30, 2009 at 5:48 AM
@motters, take a look at mss136's connectionstring, it is correct.  Also, remember you can always go to http://connectionstrings.com as well.

@mss136, that said, your connectionstring is fine - it seems to be that your sql permissions are not set up correctly - make sure to double check both Login and User permissions.
Apr 30, 2009 at 3:47 PM
hi i have all ways use windows Authorization and don't have a user name and password as i said i have all ways used windows Authorization how would i alter the conection string to do that or how do i put a user name and password on my SQL 

thank for your help!!!
Coordinator
May 1, 2009 at 9:35 AM
Here is an MSDN article that covers all  you need to know about connecting with Windows Authorization to SQL:
http://msdn.microsoft.com/en-us/library/ms998292.aspx
Jun 17, 2009 at 3:36 PM

napinski-

I'm getting the same error as mss136.  I've checked and double checked my sql permissions and am stuck.  Any suggestions?

Thanks.

 

Coordinator
Jun 18, 2009 at 5:20 AM

What is your connection string?

Are you sure that user has permissions in the database?

Oct 16, 2009 at 3:58 PM
Edited Oct 16, 2009 at 3:58 PM

I get the exact same errors.

The line 44 error if I use integrated authentication, and line 66 if I use SQL authentication.

 

<connectionStrings>
<add name="SlickTicket" connectionString="
         Data Source=database1;
         Initial Catalog=SlickTicket;
                      Integrated Security=True"
         providerName="System.Data.SqlClient"/>
</connectionStr
<connectionStrings>
<add name="SlickTicket" connectionString="
         Data Source=database1;
         Initial Catalog=SlickTicket;
                      Integrated Security=True"
         providerName="System.Data.SqlClient"/>
</connectionStrings>
or
<connectionStrings>
<add name="SlickTicket" connectionString="
         Data Source=database1;
         Initial Catalog=SlickTicket;
                          User ID=slickticket;
                          Password=*****"
         providerName="System.Data.SqlClient"/>
</connectionStrings>
Have followed the instructions to the letter and have experience setting up apps and using connection strings. SQL permissions look all ok.
Is there a work around?

 

 

Coordinator
Oct 17, 2009 at 5:11 AM

there is no 'workaround' for a bad connection string, the error you are getting:

An error occured: System.Data.SqlClient.SqlException: Cannot open database "SlickTicket" requested by the login. The login failed.

Is not a code error, it is simply saying that your connection is not working - it's that simple.

This can be many things:

  • user does not have sufficient rights
  • bad Data Source name
  • bad db name
  • bad password
  • etc.

Try connecting thorugh visual studio or with sql server mgmt studio to make sure your connection is valid.

I don't really have the know-how to troubleshoot sql problems.  There are plenty of forums out there that can likely help you better than I can.

Feb 9, 2010 at 7:56 PM
Edited Feb 9, 2010 at 8:05 PM

 

Greetings and Thank you so much, in advance for any assistance you can provide me.

----------------------

MY CONFIG: 

Host Header (subdomain) website, running on Webserver IIS 6 (W2k3 Srv), separate box for MS SQL 2005 (same lan), SQL authentication for web.config string

========================================

I've got a connection string error, but the sql account I'm using opens the db fine (remotely) via MS SQL Studio Mgr.  Here's the error (during install step 1) when I click "create tables"

------------------------// BEGIN ERROR COPY/PASTE //-----------------------------

An error occured: System.Data.SqlClient.SqlException: Login failed for user 'ZZZ\YYY$'. at System.Data.SqlClient.SqlInternalConnection.OnError

.......<<gunk>>

e:\Inetpub\xxxx\help\setup\build_database.aspx.cs:line 44

------------------------// END ERROR COPY/PASTE //-----------------------------

NOTE: Line 44 referenced above, is "conn.Open();"  so clearly, if indeed it was using the account I specified in the connection string it should work, because I tested opening the db with that same account using studio mgr.

~~~THE WIERD PART~~~

When I closely examined the error message above, I noticed that ZZZ is my domain, and YYY is the host name of the web server, as if it's trying to perhaps use a system account? of some sort, even though my web.config connection string clearly indicates a SQL auth account (which exists on the separate SQL box only).

Here's my connection string...

<connectionStrings>
  <add name="SlickTicket" connectionString="
            Data Source=sqlserver.subdom.dom.tld;
            Initial Catalog=SlickTicket;
      User ID=localsqlauthaccount;
      Password=privpasswrd;
            providerName="System.Data.SqlClient"/>
 </connectionStrings>

Best Regards,

~p

Coordinator
Feb 12, 2010 at 9:22 PM

This is clearly an error in connecting to the DB:

Login failed for user 'ZZZ\YYY$'

I am not really that experienced in this sort of thing, but first make sure with something like Visual Web Developer Express or SMSSE that you can log in with that account and credentials.