Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Database Connection error

Status
Not open for further replies.

cfcProgrammer

Programmer
Mar 1, 2006
88
CA
Hi

Could someone please help me figure out what my error is in this code. I am new to this and am unsure what it is that's causing me issues.

Here is a copy of the connection code.

Code:
<%@  Language=VBScript %>
<% ' VI 6.0 Scripting Object Model Enabled %>
<!-- #include file="../_ScriptLibrary/pm.asp" -->
<% if StartPageProcessing() Then Response.End() %>

'Create database connection
  <%
    dim strConnection, objConnection, objCommand, MyRecordSet, strStoredSQL
    Set objConnection = Server.CreateObject("ADODB.Connection")
    Set objCommand = Server.CreateObject("ADODB.Command")
    Set MyRecordSet = Server.CreateObject("ADODB.Recordset")
    MyRecordSet.CursorLocation = adUseClient
    strConnection = "Provider=SQLOLEDB; Data Source=MyDataSource; Initial Catalog=MyInitialCat; UId=uid; Pwd=pwd;"

   set MyConn = Server.CreateObject("ADODB.Connection")

   ' The following line must be changed to reflect your data source info
   MyConn.open "PROVIDER=SQLOLEDB;DRIVER={SQL Server};SERVER=myserver;DATABASE=mydatabase;UID=uid;PWD=pwd;"

   set MyCmd = server.createObject("ADODB.command")
   set MyCmd.activeConnection = Myconn

   ' Specify the name of the stored procedure you wish to call
    MyCmd.commandText = "FishStatusReportByArea"
    MyCmd.commandType = adCmdStoredProc

    'Define parameters and get the values to pass to the stored procedure
    dim Region: Region = GetRegion()
    dim Sort: Sort = Request.form("sort")
    dim FromDate: FromDate = Request.form("txtFromDay") + "/" + Request.form("txtFromMonth") + "/" + request.form("txtFromYear")
    dim ToDate: ToDate = Request.form("txtToDay") + "/" +  Request.form("txtToMonth") + "/" +  Request.form("txtToYear")

    ' Create the parameters for the Stored Procedure
    Mycmd.Parameters.Append Mycmd.CreateParameter("@Region",adVarChar,adParamInput,30,Region)
    Mycmd.Parameters.Append Mycmd.CreateParameter("@FromDate",adDate,adParamInput,10,FromDate)
    Mycmd.Parameters.Append Mycmd.CreateParameter("@ToDate",adDate,adParamInput,10,ToDate)
    Mycmd.Parameters.Append Mycmd.CreateParameter("@Sort",advarChar,adParamInput,5,Sort)

    'Call Stored Proc
    objConnection.open strConnection
    set MyRecordSet = Mycmd.execute

    'check the return value to see if there are any records returned
        if NOT (MyRecordSet.BOF or MyRecordSet.EOF) then
    'Retreive the data from the stored proc results'
            repArrRS = MyRecordSet.getrows()
            totrecs = ubound(repArrRS,2)
        dim repRow 'Row Counter
            repRow = 0
            AreRecs = true 'there are records
        else
            totrecs = 0
            AreRecs = false 'there are no records
        end if
        MyRecordSet.close() 'close the recordset
         set MyRecordSet = Nothing
The error message I am receiving is:
"Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
/DFOReps/FishStatusReport.asp, line 12"

Line 12 would be "MyRecordSet.CursorLocation = adUseClient"


Any help or guidance would be greatly appreciated.

Thank You
Colleen

cfcProgrammer
 
It doesn't look like you've declared adUseClient. Try putting this at the top.

Const adUseClient = 3

 
Thank you,
I added that to the code and now I am getting this error.

"Microsoft OLE DB Provider for SQL Server (0x80004005)
Invalid connection string attribute"

I just installed SQL Server to my local machine, is there some set up that I may not have completed. I just started in this position and the company has gone through some major turnover and there is no one here that has gone through this before so we are all struggling to piece this together. Any help would be so greatly appreciated.

Thank You
Colleen

cfcProgrammer
 
Thank you very much... I had a number of things wrong... but this site helped me out..



cfcProgrammer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top