sql connection in asp dot net

Discussion in 'Programming & Software Development' started by StarTrekCafe, Jul 1, 2017.

  1. StarTrekCafe

    StarTrekCafe Member

    Joined:
    Nov 26, 2015
    Messages:
    18
    hi. learning about web services in my diploma course, at http://www.upskilled.edu.au and using http://www.pluralsight.com and reading the transcript, ado dot net. have projects, and have a asp . net application, a class, and a win forms c #, and set up all the dlls. and and have a string connection to a string called AWConnection and also using adventure works 2014 database, and using the HumanResources.Department, Business Identity and Department ID tables. when i do a bukld and says it succeded, when i do a control f 5, says the connection could not be found, and it points to line 34, of the conn.Open(); so, do i need the sql server management studio 2014 open and did have it open, and still got the error. and also maybe set the project for the win forms, any help. how to resolve this. did ask my lecturer, but he has not got back to me, and did try googling, but could not seem to find any definite idea. any ideas, or how to fix this. it is a WinDemo. ASPDemo for the basic asp dot net empty project with web pages, and then the class is called DataLayer, and has classes, and the sql logic, then a WinDemo winforms c # application, and have all the dlls added as references. any ideas. marvin.
     
  2. rjwillers

    rjwillers Member

    Joined:
    Mar 28, 2016
    Messages:
    2
    Location:
    Perth
    You don't need sql server management open. Although the sql server services must be running in the background. This service normally starts once you have logged into windows.

    Can you provide the exception message that you get when you run debug? Its likely the case the connection string is not correct for this instance.
     
  3. OP
    OP
    StarTrekCafe

    StarTrekCafe Member

    Joined:
    Nov 26, 2015
    Messages:
    18
    hi, just rebuilt one of my projects, and when i move it from the desktop folder to c:\Marvin\Education\DiplomaSoftwareDevelopment\ContiuityAndSecurity\VisualStudi\ActiveDotNetActiveProjects\Exercises, \ChapterOne, then when i load it says the project file cannot be found. so had to then cut and paste the folder back to the desktop and import the projects or reubild, would doing a zip file when i am finished and then copying it to that folder, will then unzip, once loaded hopefully it will load fine, if i try to then create it in that folder, exceed the 255 character limit. so, that's out of the way, now, did rebuild and then got a clean build, then did a shift f 5 without debug, and got this error screen firefox so will paste below, unless it will work in debug. did not try that in debug. might try that. so here's the error message. marvin. ps: pasting below. The system cannot find the file specified

    Server Error in '/' Application.
    --------------------------------------------------------------------------------

    The system cannot find the file specified
    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.ComponentModel.Win32Exception: The system cannot find the file specified

    Source Error:


    Line 32: {
    Line 33: SqlConnection conn = new SqlConnection(ConnectionString);
    Line 34: conn.Open();
    Line 35: return conn;
    Line 36: }
    Source File: C:\Users\start\Desktop\adodotnet-fundamentals\m03-connection-exercise-files\after\DataLayer\DB.cs ** Line: 34

    Stack Trace:


    [Win32Exception (0x80004005): The system cannot find the file specified]

    [SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found
    or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider,
    error: 40 - Could not open a connection to SQL Server)]
    System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential,
    Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData
    reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling) +821
    System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo,
    DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +332
    System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey
    poolKey, DbConnectionOptions userOptions) +38
    System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
    +699
    System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
    +89
    System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean
    onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +426
    System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions,
    DbConnectionInternal& connection) +78
    System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions,
    DbConnectionInternal oldConnection, DbConnectionInternal& connection) +191
    System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1
    retry, DbConnectionOptions userOptions) +154
    System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1
    retry, DbConnectionOptions userOptions) +21
    System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) +90
    System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +217
    System.Data.SqlClient.SqlConnection.Open() +96
    DataLayer.DB.GetSqlConnection() in C:\Users\start\Desktop\adodotnet-fundamentals\m03-connection-exercise-files\after\DataLayer\DB.cs:34
    ASPDemo.Default.Page_Load(Object sender, EventArgs e) in C:\Users\start\Desktop\adodotnet-fundamentals\m03-connection-exercise-files\after\ASPDemo\Default.aspx.cs:17
    System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
    System.Web.UI.Control.OnLoad(EventArgs e) +95
    System.Web.UI.Control.LoadRecursive() +59
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +678

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

    Version Information:*Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.2046.0 rjwillers;17590468]You don't need sql server management open. Although the sql server services must be running in the background. This service normally starts once you have logged into windows.

    Can you provide the exception message that you get when you run debug? Its likely the case the connection string is not correct for this instance.[/QUOTE]
     
  4. waltermitty

    waltermitty Member

    Joined:
    Feb 19, 2016
    Messages:
    1,471
    Location:
    BRISBANE
    What's your connection string look like?

    This is the important bit:

    Are you using SQL Express or full-blown MS SQL?

    Make sure it looks something like this for express, remove \SQLEXRESS if you're using full:
    If you're not sure of the username/password, and you're able to login to SSMS with Windows Authentication, remove the userId and password and insert 'Integrated Security=true;'.

    HTH
     
  5. OP
    OP
    StarTrekCafe

    StarTrekCafe Member

    Joined:
    Nov 26, 2015
    Messages:
    18
    hi, here's my connection string. pasting below. marvin. <connectionStrings>
    <add name="AWConnection" connectionString="Data Source=localhost;Initial Catalog=AdventureWorks2014; Integrated Security=true" providerName="System.Data.SqlClient"/>
    </connectionStrings>
     
  6. waltermitty

    waltermitty Member

    Joined:
    Feb 19, 2016
    Messages:
    1,471
    Location:
    BRISBANE
    What do you see when you connect via Management Studio? Maybe try:
     
  7. OP
    OP
    StarTrekCafe

    StarTrekCafe Member

    Joined:
    Nov 26, 2015
    Messages:
    18
    ve the AWConnection and AdventureWorks2014. so do i need to add the Adventure works to the connection in visual studio. do not hear it when in the management studio, using a screen reader jaws for windows from http://www.freedomscientific.com, windows 10 64 bit, firefox. and the connection i do not hear when i expand adventure works. please advice, the last project i did was about putting in errors, and the form did come up then at the bottom got the a network error message. please help.
     
  8. OP
    OP
    StarTrekCafe

    StarTrekCafe Member

    Joined:
    Nov 26, 2015
    Messages:
    18
    hi, forgot to mention using the express 2016 version.
     
  9. Luke212

    Luke212 Member

    Joined:
    Feb 26, 2003
    Messages:
    10,224
    Location:
    Sydney
    in reference to your "Server Error in '/' Application." error, its not an sql problem. it has nothing to do with databases or sql.

    it is a project files issue. when you are moving your files you need to move the whole folder structure including the solution file, otherwise it cant find your referenced projects.

    dont change the folder structure when you move it! thats basically it.
     
  10. OP
    OP
    StarTrekCafe

    StarTrekCafe Member

    Joined:
    Nov 26, 2015
    Messages:
    18
    hi. okay thanks for that, well did let my lecturer know and he is going to get the learning materials and see if he has the same issue, well, do copy the whole folder and the projects file, as well, and okay thanks. oh well learning all the time. marvin.
     
  11. T1tan

    T1tan Member

    Joined:
    May 8, 2002
    Messages:
    6,214
    Location:
    2607 / caaaaanbwa

Share This Page

Advertisement: