Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 8th, 2003, 01:26 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: abu dbabi, , United Arab Emirates.
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default query problem

Query No1 give following error
Query 1
---------
rs.Open "SELECT contractno,recordno,category,contractor FROM arc where contractno='"&contractno&"'",cn,1,2
rs.PageSize=100

Error Type:
ADODB.Recordset (0x800A0BCD)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/dcil2/paging7.asp, line 27


When I change query ie.

Query 2
---------
rs.Open "SELECT contractno,recordno,category,contractor FROM arc where contractno='10 ’",cn,1,2
rs.PageSize=100

it give no error, whey ? how can use query no 1, I want to use query no.1 becasuse contractno value is dynamic (not constant)
and contractno received the value from the previous page.
Reply With Quote
  #2 (permalink)  
Old September 8th, 2003, 04:00 AM
Authorized User
 
Join Date: Jun 2003
Location: Manchester, , United Kingdom.
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Have you tried a space between either side of the ampersand?

rs.Open "SELECT contractno,recordno,category,contractor FROM arc where contractno='" & contractno & "'",cn,1,2

Regards
Ian
Reply With Quote
  #3 (permalink)  
Old September 8th, 2003, 04:27 AM
Authorized User
 
Join Date: Jun 2003
Location: Edinburgh, , United Kingdom.
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

Although this is nothing to do with SQL question you asked but it is good practice to check if any records are being returned and deal with it appropriately :-

If rs.BOF = True And rs.EOF = True Then
raise error
else
work with recordset
end if

Nickie
Reply With Quote
  #4 (permalink)  
Old September 8th, 2003, 05:04 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: London, , United Kingdom.
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Possibly you'd be better off using the nTRIM Functions

Code:
RTRIM(LTRIM(contractno)) ='" & contractno& "'",cn,1,2

There are two secrets to success in this world:
1. Never tell everything you know
Reply With Quote
  #5 (permalink)  
Old September 9th, 2003, 03:17 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: abu dbabi, , United Arab Emirates.
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for response. I try

if rs.BOF = True and rs.EOF = True then
 raise error
 else
 work with recordset
 end if

but it give following error

Error Type:
Microsoft VBScript compilation (0x800A03EA)
Syntax error
/dcil2/paging7.asp, line 25, column 5
work with recordset
----^

I try space between either side of the ampersand,
it give same error.

I try nTRIM function, but it give same error.

query work if constand value provide,
our contractno value come from the previous page, it is change

How can use dynamic (not constant) value in query ?
contractno value received from the previous page.







Quote:
quote:Originally posted by nbryson
 Hi

Although this is nothing to do with SQL question you asked but it is good practice to check if any records are being returned and deal with it appropriately :-

If rs.BOF = True And rs.EOF = True Then
raise error
else
work with recordset
end if

Nickie

Reply With Quote
  #6 (permalink)  
Old September 9th, 2003, 05:53 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: London, , United Kingdom.
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Can you actually execute the SQL from Query Analyzer?

There are two secrets to success in this world:
1. Never tell everything you know
Reply With Quote
  #7 (permalink)  
Old September 9th, 2003, 06:10 AM
Authorized User
 
Join Date: Jun 2003
Location: Edinburgh, , United Kingdom.
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

You need to replace 'raise error' and 'work with recordset' text with you own code.

if rs.BOF = True and rs.EOF = True then
  raise error
else
  work with recordset
end if

The error that was raised 'Microsoft VBScript compilation (0x800A03EA)
Syntax error
/dcil2/paging7.asp, line 25, column 5
work with recordset' could not compile your application as it is just text.

Just to give you an idea replace the above code with :-
if rs.BOF = True and rs.EOF = True then
  msgbox "Error retrieving recordset. description = " & Err.Description
else
  msgbox "Column 1 returned is " & rs.fields(0)
end if

See how you get on.

Nickie
Reply With Quote
  #8 (permalink)  
Old September 9th, 2003, 11:58 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: abu dbabi, , United Arab Emirates.
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for response.
I use msgbox but it give following error.

Error Type:
Microsoft VBScript runtime (0x800A0046)
Permission denied: 'msgbox'
/dcil2/tripimages/contno2ab.asp, line 107

I am using following coding.
How can use the recordset in the query ?
how can display number of records retrieve by query ?



set cn=server.CreateObject("adodb.connection")
set rs=server.CreateObject("adodb.recordset")
cn.ConnectionString="Provider=SQLOLEDB.1;Integrate d Security=SSPI;Persist Security Info=False;Initial Catalog=dcil;Data Source=dcil2"
cn.Open

contractno=Request.Form("contractno")
contractno1=Request.Form("contractno1")

ssql=contractno+contractno1

if ssql=contractno then

rs.Open "SELECT contractno,recordno,category,contractor,consultant ,Description,drawingno,approveddate,quickviewrefer ence FROM arc where contractno='" & contractno & "' order by recordno",cn,1,2
rs.PageSize=100

if rs.BOF = True and rs.EOF = True then
msgbox "error retrieving recordset. description =" & Err.Description
else
msgbox "column 1 returned is " & rs.Fields(0) // line 107

end if

Response.Write("Total No of Records = "& rs.RecordCount&"<br>")



Mateen







Quote:
quote:Originally posted by nbryson
 Hi

You need to replace 'raise error' and 'work with recordset' text with you own code.

if rs.BOF = True and rs.EOF = True then
raise error
else
work with recordset
end if

The error that was raised 'Microsoft VBScript compilation (0x800A03EA)
Syntax error
/dcil2/paging7.asp, line 25, column 5
work with recordset' could not compile your application as it is just text.

Just to give you an idea replace the above code with :-
if rs.BOF = True and rs.EOF = True then
msgbox "Error retrieving recordset. description = " & Err.Description
else
msgbox "Column 1 returned is " & rs.fields(0)
end if

See how you get on.

Nickie
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Query Problem. rupen Access 3 April 27th, 2007 07:43 AM
Query Problem bundersuk VB Databases Basics 0 December 30th, 2006 07:50 AM
query problem purnendu2311 Other Programming Languages 2 December 1st, 2006 02:53 PM
problem with query harpua Classic ASP Databases 1 January 24th, 2005 12:36 PM
Problem in query leo_vinay Classic ASP Databases 5 January 21st, 2005 06:32 AM



All times are GMT -4. The time now is 01:25 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.