Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: SQL 7 error


Message #1 by "Ramaekers Johnny" <jramaekers@s...> on Tue, 26 Sep 2000 15:36:20 +0200
This is a multi-part message in MIME format.



------=_NextPart_000_002E_01C027CF.850C8E40

Content-Type: text/plain;

	charset="iso-8859-1"

Content-Transfer-Encoding: 7bit



Hi,



It seems that i cannot get my db connection to work



this is my procedure:

I have 2 files, 1 with the dbconnection and 1 with the rest i want to do



1e is called connectdb.asp with content:



Dim strConn



Dim objConn



strConn = "Provider=SQLOLEDB; Data Source=192.168.110.2;

Database=who_is_where; UID=; PW="



Set objConn = CreateObject("ADODB.Connection")



objConn.ConnectionString = "DSN=testdb"



objConn.open







2e is called user.htm with content:



<%@ Language=VBScript %>



<!-- #include file="connectdb.asp" -->



<Form Name="ShowUsers" Method="post">



<Table>



<TR>



<TD>User Name=</TD>



<TD>



<Select Name="lstuser"></TD>



<%



Dim rsTblUSer



Dim strSQL



Dim strQuote



strQuote = Chr(50)



Set rsTblUSer = Server.Createobject("ADODB.recordset")



strSQL = "SELECT DISTINCT UserName FROM TblUser"



rsTblUser.ConnectionString = "DSN=testdb"



rsTblUser.open strSQL, rsConn, adLockReadOnly



While not rsTblUser.EOF



Response.write "<option value= "& strQuote & _rsTblUser("UserName")&">"



rsTblUser.movenext



Wend



rsTblUser.close



set rsTblUser = nothing



%>



</TR>



</Table>



</form>



Can somebody help me to find out what i'm doing wrong?



Thank you




















Message #2 by Mark Everest <Mark.Everest@t...> on Tue, 26 Sep 2000 16:27:34 +0100
This message is in MIME format. Since your mail reader does not understand

this format, some or all of this message may not be legible.



------_=_NextPart_001_01C027CE.4E4CD700

Content-Type: text/plain;

	charset="iso-8859-1"



The problem is that you are thinking like a non ASP Programmer.  The biggest

hurdle to overcome in ASP is to understand that one page should be

considered a completely separate application from another.

 

i.e. The logon you are performing on page one is being closed and forgotten

by the time page two is loaded.

 

Ways to overcome this:

 

1 - Put your connection object in a session variable - UGH TRY TO AVOID

THIS!!!!

2 - Copy and paste you logon code into the top of every page that you need

to access the database in - MESSY

3 - Include common files that do you logon and logoff in each page using

include literals - MY PREFERRED WAY

 

All of these methods will be explained in the Wrox ASP books (I expect....)

 

I hope this helps!!

 

 

 



-----Original Message-----

From: Ramaekers Johnny [mailto:jramaekers@s...]

Sent: 26 September 2000 14:36

To: ASP Databases

Subject: [asp_databases] SQL 7 error





Hi,

 

It seems that i cannot get my db connection to work

 

this is my procedure:

I have 2 files, 1 with the dbconnection and 1 with the rest i want to do

 

1e is called connectdb.asp with content:

 



Dim strConn



Dim objConn



strConn = "Provider=SQLOLEDB; Data Source=192.168.110.2;

Database=who_is_where; UID=; PW=" 



Set objConn = CreateObject("ADODB.Connection")



objConn.ConnectionString = "DSN=testdb"



objConn.open



 



2e is called user.htm with content:

 

<%@ Language=VBScript %>



<!-- #include file="connectdb.asp" -->



<Form Name="ShowUsers" Method="post">



<Table>



<TR>



<TD>User Name=</TD>



<TD>



<Select Name="lstuser"></TD>



<%



Dim rsTblUSer



Dim strSQL



Dim strQuote



strQuote = Chr(50)



Set rsTblUSer = Server.Createobject("ADODB.recordset")



strSQL = "SELECT DISTINCT UserName FROM TblUser"



rsTblUser.ConnectionString = "DSN=testdb"



rsTblUser.open strSQL, rsConn, adLockReadOnly



While not rsTblUser.EOF



Response.write "<option value= "& strQuote & _rsTblUser("UserName")&">"



rsTblUser.movenext



Wend



rsTblUser.close



set rsTblUser = nothing



%>



</TR>



</Table>



</form>



Can somebody help me to find out what i'm doing wrong?



Thank you



 



 

 

 

 

---

To place your message here, or to sponsor this list, please e-mail

mailto:p2pinfo@w...?subject=MediaPack, remembering to provide contact

details for yourself. We will e-mail you a Media Pack within 24 hours.



You are currently subscribed to asp_databases 


--- 






Message #3 by "David E" <registerukh@h...> on Tue, 26 Sep 2000 13:17:30 EDT
Johnny,



You say the 2nd file is user.htm. The thing is you have to rename this file 

to user.asp so that the server actually interprets it.



Second point is "rsTblUser.open strSQL, rsConn, adLockReadOnly", I think, 

doesnot work. Because "adLockReadOnly" comes only after the cursor type 

i.e., adOpenForwardOnly etc. You could try

rsTblUser.open strSQL, rsConn, adReadForwardOnly, adLockReadOnly, adCmdText  

. Just change the cursor type to suit requirements.



So, you could try changing the above mention points and try again.

Hope this works.



Thanks.









>-----Original Message-----

>From: Ramaekers Johnny [mailto:jramaekers@s...]

>Sent: 26 September 2000 14:36

>To: ASP Databases

>Subject: [asp_databases] SQL 7 error

>

>

>Hi,

>

>It seems that i cannot get my db connection to work

>

>this is my procedure:

>I have 2 files, 1 with the dbconnection and 1 with the rest i want to do

>

>1e is called connectdb.asp with content:

>

>

>Dim strConn

>

>Dim objConn

>

>strConn = "Provider=SQLOLEDB; Data Source=192.168.110.2;

>Database=who_is_where; UID=; PW="

>

>Set objConn = CreateObject("ADODB.Connection")

>

>objConn.ConnectionString = "DSN=testdb"

>

>objConn.open

>

>

>

>2e is called user.htm with content:

>

><%@ Language=VBScript %>

>

><!-- #include file="connectdb.asp" -->

>

><Form Name="ShowUsers" Method="post">



>

><Table>

>

><TR>

>

><TD>User Name=</TD>

>

><TD>

>

><Select Name="lstuser"></TD>

>

><%

>

>Dim rsTblUSer

>

>Dim strSQL

>

>Dim strQuote

>

>strQuote = Chr(50)

>

>Set rsTblUSer = Server.Createobject("ADODB.recordset")

>

>strSQL = "SELECT DISTINCT UserName FROM TblUser"

>

>rsTblUser.ConnectionString = "DSN=testdb"

>

>rsTblUser.open strSQL, rsConn, adLockReadOnly

>

>While not rsTblUser.EOF

>

>Response.write "<option value= "& strQuote & _rsTblUser("UserName")&">"

>

>rsTblUser.movenext

>

>Wend

>

>rsTblUser.close

>

>set rsTblUser = nothing

>

>%>

>

></TR>

>

></Table>

>

></form>

>

>Can somebody help me to find out what i'm doing wrong?

>

>Thank you

>

>

>


  Return to Index