Creating more then 1 statement in one connection in SQL server

hi
am using sql server as my database.here i cannot create more then one statement in the i connections....why does this happen
secondly is it preferable to create 'x' number of connections at the start of the application or create a connection as and when required...
Pls if anyone can help me...
regards
Praveena

hi,
if i'm not wrong try to close the already creted statment if ur creating another with the same nmae otherwise it should not be a problem creating set of statements.u can create any number of statement with a single connections.u need not open connection for every statement.hope this helps u out
bye

Similar Messages

  • ABAP statement for JDBC connection to SQL server

    Hi Gurus,
    i need to connect a WebDynpro abap to a SQL server.
    My OS is Unix so i cannot use a ODBC connection.
    Can anyone help me to know if it's possible to write an abap statement to connect the SQL server by JDBC connection?
    thanks a lot
    Regards
    Claudio.

    Hi,
          ELSEIF SCREEN-GROUP2 = 'PRO'.
          clear: list.
          if screen-name = 'ZAVBAK-ZZPROMO_ID'.
            exec sql.
       commit
              set connection :'CBREPOSITORYPRD'
            endexec.
            exec sql.
              CONNECT TO :'CBREPOSITORYPRD'
            endexec.
            exec sql.
              COMMIT
            endexec
          EXEC SQL.
              OPEN C1 FOR
              SELECT CutterRewardsUserListid,
                     SAPAccountNumber,
                     PromoID,
                     FirstName,
                     LastName
                     FROM CutterRewardsUserList
                     WHERE SAPAccountNumber = :XVBPA-KUNNR ORDER BY PromoID
            ENDEXEC.
            DO.
              EXEC SQL.
                FETCH NEXT C1 INTO :WA5
              ENDEXEC.
              IF SY-SUBRC = 0.
                PERFORM UPDATE_LIST.
              ELSE.
                EXIT.
              ENDIF.
            ENDDO.
            EXEC SQL.
              CLOSE C1
            ENDEXEC.

  • Can I create More Then One seesion in one script?

    Hi all ,
    I have got a requirment to create more then one seesion in one script only
    (means I have to login using multiple USER's in a single script.).
    and also there is no way for LOG-OFF.
    Thanks in advnc.

    Yes. This is a very common task.
    You should databank the User and Password parameters. When running many virtual users in e-load, the script will login each script/user from the list you have included in the databank. When running in Functional playback, each new iteration of a single user will login with a new user from the databank.
    There also does not need to be a logoff. In either Functional or Load playback, each time a script or a virtual user starts a new iteration it will begin as though there are no past cookies or cache files.

  • How many statement can one connection create?

    Someone said that most jdbc driver support only one statement in one connection?

    Someone said that most jdbc driver support only one statement in one connection?Either wrong or taken out of context. JDBC 1.0 supported multiple statements per connection.
    What varies is support for 'active' statements be connection. So if you are trying to get two result sets from two different statements that both use the same connection your results can vary. JDBC 2/3 is supposed to support this but you had better test it first.

  • Re: How to create More two class with one object

    haii,
             i have small information How to create More two class with one object,
    bye
    bye
    babu

    Hello
    I assume you want to create multiple instance of your class.
    Assuming that you class is NOT a singleton then simply repeat the CREATE OBJECT statement as many times as you need.
    TYPES: begin of ty_s_class.
    TYPES: instance   TYPE REF TO zcl_myclass.
    TYPES: end of ty_s_class.
    DATA:
      lt_itab      TYPE STANDARD TABLE OF ty_s_class
                     WITH DEFAULT KEY,
      ls_record  TYPE ty_s_class.
      DO 10 TIMES.
        CLEAR: ls_record-instance.
        CREATE OBJECT ls_record-instance.
        APPEND ls_record TO lt_itab.
      ENDDO.
    Regards
      Uwe

  • Can't Create a Data Source - Failed to test connection. [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied

    Hi there,
    I am having a serious issue with The Power BI Data Management Gateway which I am hoping that someone can help me with.
    Basically I am setting a connection between a Power BI demo site and a SQL 2012 Database based on Azure. The Data Management Gateway and is up and running, and Power BI has managed to connect to it successfuly.
    By following the tutorials at
    here I was able to successful create my Data Connection Gateway with a self-signed certificate.
    However, when trying to create the data source I come into problems. The Data Source Manager manages to successfully resolve the hostname, as per the screenshot below:
    Bear in mind that I exposed the require ports in Azure as endpoints and I managed to modify my hosts file on my local machine so I could access the SQL server hosted in Azure using its internal name -- otherwise I would not be able to get this far.
    However the creation of the data source also fails when trying to created it whilst logged in the SQL server in question:
    The Data Source Manager returns the error when using the Microsoft OLE DB Provider for SQL Server:
    Failed to test connection. [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied
    I tried using the SQL Server Native Client 11.0 instead but I also get an error. This time the error is:
    Failed to test connection. Login timeout expiredA network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.Named Pipes Provider: Could not open a connection to SQL Server [53]. 
    Some considerations
    If I provide an invalid username/password, the Data Source Manager does say that the username and password is incorrect.
    Firewall is turned off in the SQL Server (either way, this error also happens if I try top use the Data Source Manager whilst logged in the SQL Server itself).
    SQL Profiler does not show any attempt of connection.
    The SQL server instance in question is the default one.
    The error happens regardless if I select the option to encrypt connection or not.
    In SQL Configuration manager I can see that all protocols are enabled (TCP/IP, Named Pipes and Shared Memory.
    The Event Viewer does not provide any further errors than the one I have copied in this post.
    I'm at a loss here. Could someone please advise what might I be doing wrong?
    Regards,
    P.

    Here is what I had to do to solve this issue:
    Basically I had to add the MSSQL TCP/IP port as an end-point in Azure. After I did that, then I was able to create the data-source. However, I was only able to authenticate with a SQL account, as any domain account would return me an error saying that the
    domain isn't trusted.
    What puzzles me here is how come the Data Source Manager would inform me that an account username/password was invalid, but it would fail/timeout if I provided valid credentials (!?!?!!?)

  • How to create a DSN-less connection to SQL Server for linked tables in Access

    hey
    i cant understand how i use that Function
    if that information what you need
     stLocalTableName: dbo_user_name
    stRemoteTableName: user_name
    stServer :sedo2015.mssql.somee.com
    stDatabase :sedo2015
    stUsername :sedo_menf_SQLLogin_1
    stPassword :123456789
    how will be that Function??
    please write that Function to me
    '//Name : AttachDSNLessTable
    '//Purpose : Create a linked table to SQL Server without using a DSN
    '//Parameters
    '// stLocalTableName: Name of the table that you are creating in the current database
    '// stRemoteTableName: Name of the table that you are linking to on the SQL Server database
    '// stServer: Name of the SQL Server that you are linking to
    '// stDatabase: Name of the SQL Server database that you are linking to
    '// stUsername: Name of the SQL Server user who can connect to SQL Server, leave blank to use a Trusted Connection
    '// stPassword: SQL Server user password
    Function AttachDSNLessTable(stLocalTableName As String, stRemoteTableName As String, stServer As String, stDatabase As String, Optional stUsername As String, Optional stPassword As String)
    On Error GoTo AttachDSNLessTable_Err
    Dim td As TableDef
    Dim stConnect As String
    For Each td In CurrentDb.TableDefs
    If td.Name = stLocalTableName Then
    CurrentDb.TableDefs.Delete stLocalTableName
    End If
    Next
    If Len(stUsername) = 0 Then
    '//Use trusted authentication if stUsername is not supplied.
    stConnect = "ODBC;DRIVER=SQL Server;SERVER=" & stServer & ";DATABASE=" & stDatabase & ";Trusted_Connection=Yes"
    Else
    '//WARNING: This will save the username and the password with the linked table information.
    stConnect = "ODBC;DRIVER=SQL Server;SERVER=" & stServer & ";DATABASE=" & stDatabase & ";UID=" & stUsername & ";PWD=" & stPassword
    End If
    Set td = CurrentDb.CreateTableDef(stLocalTableName, dbAttachSavePWD, stRemoteTableName, stConnect)
    CurrentDb.TableDefs.Append td
    AttachDSNLessTable = True
    Exit Function
    AttachDSNLessTable_Err:
    AttachDSNLessTable = False
    MsgBox "AttachDSNLessTable encountered an unexpected error: " & Err.Description
    End Function

    thanks more thanks for you
    look i add that code in form
    it worked but i cant add recored  why ??
    Private Sub Form_Open(Cancel As Integer)
    Call AttachDSNLessTable("dbo_user_name", "user_name", "sedo2015.mssql.somee.com", "sedo2015", "sedo_menf_SQLLogin_1", "123456789")
    End Sub

  • Unable to establishing a connection to SQL Server created via SqlManagementClient

    Goal:
    create an Azure SQL Server via .NET (Microsoft.WindowsAzure.Management.Sql.Modules.SqlManagementClient) and add a database to it.
    Problem:
    I am NOT able to access the newly created server from .Net code.
    Description:
    Using SqlManagementClient I SUCCESFULLY create a new Azure SQL Server (see code below).
    After creating the server, I am able to access the new server from Azure Portal.
    * firewall rule show valid client machine
    * "Windows Azure Services" is set to "Yes"
    An error occures when I try connecting to the database using the same user and pwd used to create it. 
    /* the following code results in a connection failure  */
    //string server = <name of newly created sql server>
    //string db = <name of new database to create, inside of the server>
    public void CreateDatabase(string server, string db)
     using (ReliableSqlConnection conn = new ReliableSqlConnection(
                    Configuration.GetConnectionString(server, "Master"),
                    SqlRetryPolicy,
                    SqlRetryPolicy))
                    conn.Open();   //// throws System.Data.SqlClient.SqlException
        //// A network-related or instance-specific error occurred while establishing a connection to SQL Server.
                    SqlCommand cmd = conn.CreateCommand();
    /* the following code creates a sql server and firewall rules */
    ServerCreateResponse response;
    SubscriptionCloudCredentials creds;
    X509Certificate2 cert;
    //// Gets the certificate  
    cert = CredentialUtil.GetCertificate(certificateStoreName, certificateStoreLocation, certificateThumbprint);
    //// Using the certificate and the subscription build credential
    creds = new CertificateCloudCredentials(azureSubscriptionId, cert);
    //// using creditials create server and set firewall rules
    using (SqlManagementClient client = new SqlManagementClient(creds))
            response = client.Servers.Create(new ServerCreateParameters()
                    AdministratorPassword = sqlPwd,
                    AdministratorUserName = sqlUser,
             Location = location
            if (response.StatusCode == HttpStatusCode.Created)
      //// 0.0.0.0 is added to enable "Windows Azure Services" on the "Configure" tab.
      //// <MyInternetIp> would be my actual IP address.
      //// - (which works for other servers that i have manualy registered
      validIPs = new List<string>() {"0.0.0.0", "<MyInternetIp>"};
      CreateFireWallRule(client, response.ServerName, validIPs);
    //// Adds IP to Azure firewall.
    private static void CreateFireWallRule(SqlManagementClient client, string azureServerName, IEnumerable<string> validIPs)
                foreach (string ip in validIPs)
                    FirewallRuleCreateParameters rule = new FirewallRuleCreateParameters() { Name = string.Format("Allow {0} - {1}", Environment.MachineName, ip), StartIPAddress
    = ip, EndIPAddress = ip };
                    client.FirewallRules.Create(azureServerName, rule);
    /// Error
    System.Data.SqlClient.SqlException was unhandled
      HResult=-2146232060
      Message=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)
      Source=.Net SqlClient Data Provider
      ErrorCode=-2146232060
      Class=20
      LineNumber=0
      Number=53
      Server=""
      State=0

    Using SqlManagementClient I SUCCESFULLY create a new Azure SQL Server.
    ServerCreateResponse response;
    SubscriptionCloudCredentials creds;
    X509Certificate2 cert;
    cert = CredentialUtil.GetCertificate(parameters.CertificateStoreName, parameters.CertificateStoreLocation, parameters.CertificateThumbprint);
    creds = new CertificateCloudCredentials(parameters.AzureSubscriptionId, cert);
    using (SqlManagementClient client = new SqlManagementClient(creds))
                    response = client.Servers.Create(new ServerCreateParameters()
                        AdministratorPassword = parameters.SqlPwd,
                        AdministratorUserName = parameters.SqlUser,
                        Location = parameters.Location
                    if (response.StatusCode == HttpStatusCode.Created)
                        CreateFireWallRule(client, response.ServerName, parameters.ValidIPs);

  • Some times on Tomcat start up it creates SSL error while JDBC connection to SQL server

    We are using Apache Tomcat 6 and SQL server 2008 on production. In the application in ServletContextListner we make DB connection to read some property from DB. When we restart the Tomcat 6.0 in that case sometimes it does not gets DB connection till 5 to
    10 minutes. It does not happen every time. We are using JNDI for getting the Datasource objectand using SQL JDBC 3.0 driver. We get following error in log
    org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "Connection reset by peer: socket write error".)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1225)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
    at com.rightwave.util.RWDBConnectionManager.getConnection(RWDBConnectionManager.java:145)
    at com.rightwave.util.RWDataBaseDAO.executeQuery(RWDataBaseDAO.java:306)
    at com.rightwave.util.RWDataBaseDAO.executeQuery(RWDataBaseDAO.java:289)
    at com.rightwave.admin.RWApplicationContext.setMConfigurationProperties(RWApplicationContext.java:226)
    at com.rightwave.admin.RWAdminApplicationContext.initialize(RWAdminApplicationContext.java:85)
    at com.rightwave.admin.RWServletContextListener.contextInitialized(RWServletContextListener.java:186)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:627)
    at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    at org.apache.catalina.core.StandardService.start(StandardService.java:516)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
    Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "Connection reset by peer: socket write error".
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1368)
    at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1412)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1058)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:833)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:716)
    at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:841)
    at org.apache.tomcat.dbcp.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
    at org.apache.tomcat.dbcp.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:294)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1247)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1221)
    ... 31 more
    Caused by: java.io.IOException: Connection reset by peer: socket write error
    at com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream.ensureSSLPayload(IOBuffer.java:500)
    at com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream.readInternal(IOBuffer.java:570)
    at com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream.read(IOBuffer.java:562)
    at com.microsoft.sqlserver.jdbc.TDSChannel$ProxyInputStream.readInternal(IOBuffer.java:757)
    at com.microsoft.sqlserver.jdbc.TDSChannel$ProxyInputStream.read(IOBuffer.java:745)
    at com.sun.net.ssl.internal.ssl.InputRecord.readFully(Unknown Source)
    at com.sun.net.ssl.internal.ssl.InputRecord.read(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(Unknown Source)
    at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1379)
    ... 39 more
    Urgent help will be appreciated. 

    So, you've got a network error.. Check your physical layer.

  • Problem when create connection to SQl Server ( charecter set cp1255 not found ))

    Hello my name is Ron ,
    i want to connect to SQL SERVER with the microsoft driver
    from Java ( with jDeveloper ) .
    then i did the following steps:
    1) i download and install the jdbc driver for Sql server
    on my machine ( windows XP with , JDK 1.3 )
    2) i update my classpath with the .Jar lib file of the driver .
    3) when creating the connection
    i'm using the
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
    this is Ok , the driver was loaded .
    4) when trying the GetConnction
    Connection conn = DriverManager.getConnection
    ("jdbc:microsoft:sqlserver://server1:1433","username","secret");
    i get the following error:
    [Microsoft][SQLServer 2000 Driver for JDBC]Character set CP1255 not found in com.microsoft.util.transliteration.properties.
    please help me with this . any idea ?
    thanks in advance
    Roni

    Ron,
    Try following this document
    http://otn.oracle.com/products/jdev/howtos/bc4j/bc_psqlserverwalkthrough.html
    from the how-tos archive.
    Also, try to change the compiler encoding to UTF-8. you do this in the project setting window.
    http://otn.oracle.com/products/jdev/htdocs/vcmigration/weblogic/unicode.gif
    http://otn.oracle.com/products/jdev/htdocs/vcmigration/weblogic/unicode2.gif
    good luck

  • Named Pipes provider, error:40 could not open a connection to sql server. Only happens on one of the front end SRS servers

    when testing a datasource connection I get the following error.
    Named Pipes provider, error:40 could not open a connection to sql server.
    I've read all the posts on this and nothing works.  This is a scale out deployment and the connection
    works from the other server I have setup with SRS that is connected to the same backend SRS databases.  It just doesn't work from one of the SRS front ends.  I'm at a loss..  please help

    Enable both named pipe and TCP communications.
    Make sure client is using the same (named) pipe name as server for connection.
    Kalman Toth Database & OLAP Architect
    Free T-SQL Scripts
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • When i plug my phone into itunes for the ios update, it downloads but then says it cant connect to the server. How do i get my update?

    When i plug my phone into itunes for the ios update, it downloads but then says it cant connect to the server. How do i get my update?

    Here are Apple Steps for Error 21:
    This error typically occur when security software interferes with the restore and update process. FollowTroubleshooting security software issues to resolve this issue. In rare cases, these errors may be a hardware issue. If the errors persist on another computer, the device may need service.
    My additional advice:
    Also Error 21 can occur with DFU Mode Restore, try Recovery Mode Restore. Restart computer. Open iTunes on computer. Connect iPhone to computer. Hold both home and power buttons until iTunes recognizes iPhone in Recovery Mode. This usually takes about 20 seconds of holding both buttons. Click Restore button of iTunes.

  • Creating connection to SQl Server

    I'm trying to establish a connection to sql server. I have set the third party JDBC drivers to point to jtds-1.2.jar. When I try and create a new connection I get Status : Failure -I/O Error: SSo Failed : Native SSPI library not loaded. Check the java.library.path system property.
    Any ideas on what I need to do to fix this?
    Thanks
    Steve

    We got the same error message with the current version of SQL Developer 1.1.3 and the early adaptor version of SQL Developer Migration Workbench on Windows
    The solution we found on the net (http://www.nabble.com/MSSQL-JDBC-driver-t361081.html) was
    According to the README.SSO file in the JDTD installation you must have the ntlmauth.dll file in your PATH.
    Make sure that you do, or try to set the java.library.path system property to the directory containing this
    file, that is <jtds-dir>/SSO

  • Creating ODBC Connections to SQL Server

    I have posted a Question to two Forums about a problem I'm having connecting to SQL Server using an ODBC Connection.  Suddenly we can connect using on the IP Address of the virtual server not its name.  So we can connect using 192.168.16.122\GEMSQLSRVR
    but not GEM-SERVER\GEMSQLSRVR.  Where should I be asking the question?

    Seems you have a name resolution problem. You could try them here for SQL
    SQL Server Data Access forum on MSDN
    or depending on you OS
    Windows 7 / 8.1 IT Pro forums on TechNet
     Windows Server General forum on TechNet
    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]
    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

  • 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. (p

    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)(Microsoft SQL Server, Error: 2)
    The system cannot find the file specified
    Cannot connect to COWBOYS.
    Here are the technical details===================================
    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) (.Net SqlClient Data Provider)
    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&EvtSrc=MSSQLServer&EvtID=2&LinkId=20476
    Error Number: 2
    Severity: 20
    State: 0
    Program Location:
       at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
       at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover)
       at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
       at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer
    timeout)
       at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
       at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance,
    SqlConnectionString userConnectionOptions, SessionData reconnectSessionData)
       at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
       at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
       at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
       at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
       at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
       at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
       at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
       at System.Data.SqlClient.SqlConnection.Open()
       at Microsoft.SqlServer.Management.SqlStudio.Explorer.ObjectExplorerService.ValidateConnection(UIConnectionInfo ci, IServerType server)
       at Microsoft.SqlServer.Management.UI.ConnectionDlg.Connector.ConnectionThreadUser()
    ===================================
    The system cannot find the file specified
    I have tried from so many forms. This is so frustrating. Thank for everyone/anyone who wants to help. So this is what happened: I had to uninstall my previous sqlserver 2012(which worked great) for some reason, and I uninstalled everything from that download.
    Then I installed the trial edition of sql server 2012 (64 Bit) and It wouldn't connect to the database. (Error mentioned above.) My local DB is COWBOYS. (COWBOYS is also my computer name.) After this, I have tried downloading sqlexpress and sqlserver 64bit
    many times and cannot connect to my local DB. 
    How do I connect to my Local DB? 
    Also, I think this might help: (When I run sqlserve.exe, which I was able to find in C:\Program Files\Microsoft SQL Server\110\LocalDB\Binn, I get an error: Your SQL server installation is either corrupt or has been tampered with(Error getting
    instance ID from name). Please uninstall then re-run setup to correct this problem.
    I would happily re install it, if it wasn't my 20th time.
    I don't have any remote connections, I don't use username/password, only window authentication. I work mostly on visual studio, but without able to store /retrieve data, I don't know how to survive.
    May be the solution is very simple, but I am too frustrated. 
    Some of the things I have tried:
    From a command prompt, enter one of the following commands:
    net start "SQL Server Agent (MSSQLSERVER)" OR 
    net start "SQL Server Agent(instancename)"(for instance)
    on my sql configuration, I cannot start anything because there is nothing there to start. I can post more details, if that would help. Also, some more details about the error:
    Details
    Product:
    SQL Server
    ID:
    2
    Source:
    MSSQLServer
    Version:
    10.0
    Component:
    SQLEngine
    Message:
    An error has occurred while establishing a connection to the server. When connecting to SQL Server, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error:
    40 - Could not open a connection to SQL Server) (.Net SqlClient Data Provider)
    Explanation
    SQL Server did not respond to the client request because the server is probably not started.
    User Action
    Make sure that the server is started.
    Version:
    9.0
    Component:
    SQLEngine
    Message:
    An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error:
    40 - Could not open a connection to SQL Server) (.Net SqlClient Data Provider)
    Explanation
    SQL Server did not respond to the client request because the server is probably not started.
    User Action
    Make sure that the server is started.
    Any one that can help me, I will be greatful. Thank you so much. p.s. please ask me anything if you have any questions.

    It sounds like there are a couple things going on here.  First check if you have a successful install of SQL Server, then we'll figure out the connection issues.
    Can you launch SQL Server Configuration Manager and check for SQL Server (MSSQLSERVER) if default instance or SQL Server (other name) if you've configured your instance as a named instance.  Once you find this, make sure the service is started. 
    If not started, try to start it and see if it throws an error.  If you get an error, post the error message your hitting.  If the service starts, you can then launch SSMS and try to connect.  If you have a default instance, you can use the machine
    name in the connection dialog.  Ex:  "COWBOYS" where Cowboys is the machine name.  However, if you named the SQL Server instance during install, you'll need to connect using the machine\instance format.  Ex:  COWBOYS\Romo (where Romo
    is the instance name you set during install).
    You can also look at the summary.txt file in the SQL Server setup error logs to see what happened on the most recent install.  Past install history is archived in the log folder if you need to dig those up to help troubleshoot, but the most
    recent one may help get to the bottom of it if there is an issue with setup detecting a prior instance that needs to be repaired.
    Thanks,
    Sam Lester (MSFT)
    http://blogs.msdn.com/b/samlester
    This posting is provided "AS IS" with no warranties, and confers no rights. Please remember to click
    "Mark as Answer" and
    "Vote as Helpful" on posts that help you. This can be beneficial to other community members reading the thread.

Maybe you are looking for