Connection to sql server not getting established

  • Hi,

    I have an application in Acces that connects to sql server. I am using ADO to connect to the sql server from the form. The funny thing is that I have used this method in another access sql application. i know this works. However in the current system it is not working. I am pretty sure that the sql server is not getting connected. I want to run a stored procedure using a ADO command object. When I am clicking the conn.provider the provider should come automatically in a list. This is not coming up. Similarly with other connection related steps eg. ActiveConnection should come up as a list and it is not. I really really appreciate any help.

    The system compiles and has the same reference as that of another successful access sql application. I do not know why the connection is not getting established.

    CODE:

    Dim lngAffected As Long

    Set conn = New ADODB.Connection

    Set lcmStatus = New ADODB.Command

    conn.Provider = "SQLOLEDB"

    conn.ConnectionString = "Provider=SQLOLEDB.1;Initial Catalog=PWO;Data Source=localhost;User ID=sa;Password=test;"

    conn.CursorLocation = adUseClient

    conn.Open

    lcmStatus.CommandType = adCmdStoredProc

    lcmStatus.CommandText = "usp_sp_insert_dbo_PWO_Status_1_single"

    Set lcmStatus.ActiveConnection = conn

    lcmStatus.Parameters.Append cmdInsert.CreateParameter("@userprefix", _

    adVarWChar, adParamInput, 10, var_QuotePrefix)

    lcmStatus.Parameters.Append cmdInsert.CreateParameter("@usernumber", _

    adVarWChar, adParamInput, 10, var_QuoteNumber)

    lcmStatus.Parameters.Append cmdInsert.CreateParameter("@userrevision", _

    adVarWChar, adParamInput, 10, var_QuotePWORevision)

    lcmStatus.Parameters.Append cmdInsert.CreateParameter("@userpricerevision", _

    adVarWChar, adParamInput, 10, var_QuotePriceRevision)

    lcmStatus.Parameters.Append cmdInsert.CreateParameter("@userscenario", _

    adInteger, adParamInput, 4, var_NextScenarioNumber)

    lcmStatus.Execute lngAffected, , adExecuteNoRecords

    ' Deallocate

    Set lcmStatus = Nothing

    ' Return True if a consultant was assigned

    If lngAffected = 1 Then

    AddToStatus = True

    Else

    AddToStatus = False

    End If

  • [font="Verdana"]

    For more information, refer...

    http://www.connectionstrings.com/?carrier=sqlserver

    Mahesh

    [/font]

    MH-09-AM-8694

  • Thanks for help. I have already solved the issue. Regards

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply