Connection to Sql Server error

Results 1 to 2 of 2

Thread: Connection to Sql Server error

  1. #1
    Join Date
    Dec 1969

    Default Connection to Sql Server error

    here is all the relevant code.<BR>Please check it out.<BR><BR><BR>&#039;Gives the error<BR>ADODB.Recordset error &#039;800a0bb9&#039; <BR><BR>Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another. <BR><BR>/complit/Project/newsoftwarequest.asp, line 27 <BR><BR><BR>&#039;newsoftwarequest.asp file<BR>&#039;reference the Session connection variable<BR>cn = Session("cnn")<BR><BR> &#039;create a recordset <BR>Set QuestionNo = Server.CreateObject("ADODB.Recordset")<BR>querystr 3 = "SELECT count(*) as cnt FROM dbo.Software" &#039;get the number of records<BR>QuestionNo.Open querystr3, cn<BR>While not QuestionNo.EOF<BR> no_records = QuestionNo("cnt")<BR> QuestionNo.MoveNext<BR>Wend<BR>QuestionNo.Close<BR ><BR>&#039;global.asa file<BR><BR>&#039;Create an ADO Connection<BR> Set cn = Server.CreateObject("ADODB.Connection")<BR> <BR> &#039;Specify the OLE DB provider<BR> cn.Provider = "sqloledb"<BR> <BR> &#039;Specify connection string on Open method<BR> ProvStr = "Server=;Database=project;UID=sa;PWD=;"<B R> cn.Open ProvStr<BR> <BR> Set Session("cnn") = cn<BR> <BR>END Sub<BR><BR>Sub Session_OnEnd &#039;Runs when a user&#039;s session times out or quits the application<BR><BR> &#039;close the data connection<BR> cn.Close<BR> <BR>END Sub

  2. #2
    Join Date
    Dec 1969


    why do u want to open a connection and be open in the global.asa file itself. u know how costly a connection to the database is?<BR><BR>open the connection and recordset in the asp page u want and dont use sesions for holding connection state. it is not the best way to program db codes. what will happen if ur session expires, u get the idea now?<BR><BR>so do like,<BR>set conn=server.createobject("adodb.connection")<BR>co db connection string<BR>set rs=....<BR> sql,conn followd by locks type and cursor type<BR>and u need not use a while loop in this case as there will be only one record that ill be generated.. so use<BR><BR>if not isNull(rs(0)) then<BR>count=rs(0)<BR>else<BR>response.write "no records"<BR>end if<BR>rs.close<BR>conn.close<BR>set rs=nothing<BR>set conn=nothing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts