473,786 Members | 2,672 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Retriving data from Database



I have a form that displays information selected from an Access Data
base. A select statement is used to do this on my asp page
SQLQuery = "SELECT * FROM tblopgaCOm2 WHERE billNo = '"

& Request.Form("B ILLNO") & "' AND area LIKE 'AUDIT'"

billNo and area are the 2 fields used together to make the record we
need unique. example Bill d456(billNo) can be
assigned to various depts(area). as many depts as it is
assigned rep the many times it is used. ie therefore Bill d456
assigned to the audit, finance and Hresources appears 3 times.
Therefore for me to pull the record rep Bill d456 for the audit dept I
have do a select * by billNo and area like "AUDIT" as above.
This infor like I said is displayed in a form so the user also has the
ability to add or update this displayed infor.
Now this is what I want to do,
include an input box(readonly) that is also required to capture the
various dept(area) where the Billno d456 has been assigned.just one
input box that will show me that the same billNo d456 was also assigned
to not just the audit dept but also the finance & humanresource dept. so
the input box will just show the result "audit, finance & Hresource.
How do I get around this .
Is it to have 2 select statements on a page /form??
If that is the answer then how do I go about that
below is my exsisting script.Thanks as always!!!

<%

Set Conn = Server.CreateOb ject("ADODB.Con nection")
Set Rs = Server.CreateOb ject("adodb.Rec ordset")
Conn.Open "eiwp"
SQLQuery = "SELECT * FROM tblopgaCOm2 WHERE billNo = '" &
Request.Form("B ILLNO") & "' AND area LIKE 'AUDIT'"
RS.Open SQLquery, Conn

%>

<table border="0" cellpadding="2" cellspacing="4" width="120%">
<tr>
<td width="100%">

<form method="POST" action="legconf irm.asp" >
<table border="0" cellpadding="2" cellspacing="4" width="121%"
height="172">
<tr>
<td width="20%" bgcolor="#99CCF F" height="36"> <b><font
size="2">ID#:
</font> </b><input type="text" name="Test"
style="backgrou nd-color: #D2D2D2" size="9" value="<%=rs("t est")%>"
readonly></td>
<td width="49%" bgcolor="#99CCF F" height="36"> <b><font
size="2">bill</font>#</b>
<input type="text" name="billNo" style="backgrou nd-color: #D2D2D2"
size="9" value="<%=rs("b illno")%>" readonly></td>
<td width="129%" height="36" bgcolor="#C0C0C 0">
<p align="left"><b ><font color="#000080" ><input type="text"
name="area" style="backgrou nd-color: #D2D2D2; color: #FF0000;
font-weight: bold; text-align: Left" size="8" value="<%=rs("a rea")%>"
readonly></font></b></p>
</td>
<td width="28%" bgcolor="#99CCF F" height="36"><fo nt
size="2"><b>tim e:<input type="text" name="Time" readonly
style="backgrou nd-color: #D2D2D2" size="10"
value="<%=rs("u pddate")%>"></b></font></td>
</table>
</form>

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #1
11 1865
Have some patience, you just posted after the end of the work day yesterday,
so people really haven't even had an hour to digest this yet. You have a
lot of information here, so it's not going to be a two-word or five-minute
answer. But if you keep repeatedly posting the same question over and over
again in new threads, you will be put on ignore lists quite fast.

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/


"iffy agbim" <ia******@hotma il.com> wrote in message
news:ew******** ******@TK2MSFTN GP12.phx.gbl...


I have a form that displays information selected from an Access Data
base. A select statement is used to do this on my asp page
SQLQuery = "SELECT * FROM tblopgaCOm2 WHERE billNo = '"

& Request.Form("B ILLNO") & "' AND area LIKE 'AUDIT'"

billNo and area are the 2 fields used together to make the record we
need unique. example Bill d456(billNo) can be
assigned to various depts(area). as many depts as it is
assigned rep the many times it is used. ie therefore Bill d456
assigned to the audit, finance and Hresources appears 3 times.
Therefore for me to pull the record rep Bill d456 for the audit dept I
have do a select * by billNo and area like "AUDIT" as above.
This infor like I said is displayed in a form so the user also has the
ability to add or update this displayed infor.
Now this is what I want to do,
include an input box(readonly) that is also required to capture the
various dept(area) where the Billno d456 has been assigned.just one
input box that will show me that the same billNo d456 was also assigned
to not just the audit dept but also the finance & humanresource dept. so
the input box will just show the result "audit, finance & Hresource.
How do I get around this .
Is it to have 2 select statements on a page /form??
If that is the answer then how do I go about that
below is my exsisting script.Thanks as always!!!

<%

Set Conn = Server.CreateOb ject("ADODB.Con nection")
Set Rs = Server.CreateOb ject("adodb.Rec ordset")
Conn.Open "eiwp"
SQLQuery = "SELECT * FROM tblopgaCOm2 WHERE billNo = '" &
Request.Form("B ILLNO") & "' AND area LIKE 'AUDIT'"
RS.Open SQLquery, Conn

%>

<table border="0" cellpadding="2" cellspacing="4" width="120%">
<tr>
<td width="100%">

<form method="POST" action="legconf irm.asp" >
<table border="0" cellpadding="2" cellspacing="4" width="121%"
height="172">
<tr>
<td width="20%" bgcolor="#99CCF F" height="36"> <b><font
size="2">ID#:
</font> </b><input type="text" name="Test"
style="backgrou nd-color: #D2D2D2" size="9" value="<%=rs("t est")%>"
readonly></td>
<td width="49%" bgcolor="#99CCF F" height="36"> <b><font
size="2">bill</font>#</b>
<input type="text" name="billNo" style="backgrou nd-color: #D2D2D2"
size="9" value="<%=rs("b illno")%>" readonly></td>
<td width="129%" height="36" bgcolor="#C0C0C 0">
<p align="left"><b ><font color="#000080" ><input type="text"
name="area" style="backgrou nd-color: #D2D2D2; color: #FF0000;
font-weight: bold; text-align: Left" size="8" value="<%=rs("a rea")%>"
readonly></font></b></p>
</td>
<td width="28%" bgcolor="#99CCF F" height="36"><fo nt
size="2"><b>tim e:<input type="text" name="Time" readonly
style="backgrou nd-color: #D2D2D2" size="10"
value="<%=rs("u pddate")%>"></b></font></td>
</table>
</form>

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 19 '05 #2
You could do this within your page:
<select name='billDept' >
<%set sql2 = conn.execute("S ELECT * FROM tblopgaCOm2 WHERE billNo = '" &
Request.Form("B ILLNO") "'")
while not sql2.eof%>
<Option value='<%=sql2( "area")%>'> <%=sql2("area") %></option>
<%sql2.MoveNe xt
wEnd%>
</Select>

"iffy agbim" <ia******@hotma il.com> wrote in message
news:ew******** ******@TK2MSFTN GP12.phx.gbl...


I have a form that displays information selected from an Access Data
base. A select statement is used to do this on my asp page
SQLQuery = "SELECT * FROM tblopgaCOm2 WHERE billNo = '"

& Request.Form("B ILLNO") & "' AND area LIKE 'AUDIT'"

billNo and area are the 2 fields used together to make the record we
need unique. example Bill d456(billNo) can be
assigned to various depts(area). as many depts as it is
assigned rep the many times it is used. ie therefore Bill d456
assigned to the audit, finance and Hresources appears 3 times.
Therefore for me to pull the record rep Bill d456 for the audit dept I
have do a select * by billNo and area like "AUDIT" as above.
This infor like I said is displayed in a form so the user also has the
ability to add or update this displayed infor.
Now this is what I want to do,
include an input box(readonly) that is also required to capture the
various dept(area) where the Billno d456 has been assigned.just one
input box that will show me that the same billNo d456 was also assigned
to not just the audit dept but also the finance & humanresource dept. so
the input box will just show the result "audit, finance & Hresource.
How do I get around this .
Is it to have 2 select statements on a page /form??
If that is the answer then how do I go about that
below is my exsisting script.Thanks as always!!!

<%

Set Conn = Server.CreateOb ject("ADODB.Con nection")
Set Rs = Server.CreateOb ject("adodb.Rec ordset")
Conn.Open "eiwp"
SQLQuery = "SELECT * FROM tblopgaCOm2 WHERE billNo = '" &
Request.Form("B ILLNO") & "' AND area LIKE 'AUDIT'"
RS.Open SQLquery, Conn

%>

<table border="0" cellpadding="2" cellspacing="4" width="120%">
<tr>
<td width="100%">

<form method="POST" action="legconf irm.asp" >
<table border="0" cellpadding="2" cellspacing="4" width="121%"
height="172">
<tr>
<td width="20%" bgcolor="#99CCF F" height="36"> <b><font
size="2">ID#:
</font> </b><input type="text" name="Test"
style="backgrou nd-color: #D2D2D2" size="9" value="<%=rs("t est")%>"
readonly></td>
<td width="49%" bgcolor="#99CCF F" height="36"> <b><font
size="2">bill</font>#</b>
<input type="text" name="billNo" style="backgrou nd-color: #D2D2D2"
size="9" value="<%=rs("b illno")%>" readonly></td>
<td width="129%" height="36" bgcolor="#C0C0C 0">
<p align="left"><b ><font color="#000080" ><input type="text"
name="area" style="backgrou nd-color: #D2D2D2; color: #FF0000;
font-weight: bold; text-align: Left" size="8" value="<%=rs("a rea")%>"
readonly></font></b></p>
</td>
<td width="28%" bgcolor="#99CCF F" height="36"><fo nt
size="2"><b>tim e:<input type="text" name="Time" readonly
style="backgrou nd-color: #D2D2D2" size="10"
value="<%=rs("u pddate")%>"></b></font></td>
</table>
</form>

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 19 '05 #3
iffy agbim wrote:
I have a form that displays information selected from an Access Data
base. A select statement is used to do this on my asp page
SQLQuery = "SELECT * FROM tblopgaCOm2 WHERE billNo = '"

& Request.Form("B ILLNO") & "' AND area LIKE 'AUDIT'"

billNo and area are the 2 fields used together to make the record we
need unique. example Bill d456(billNo) can be
assigned to various depts(area). as many depts as it is
assigned rep the many times it is used. ie therefore Bill d456
assigned to the audit, finance and Hresources appears 3 times.
Therefore for me to pull the record rep Bill d456 for the audit dept I
have do a select * by billNo and area like "AUDIT" as above.
No you don't. Without a wildcard, LIKE is the same as =. You may as well use
area='AUDIT'
This infor like I said is displayed in a form so the user also has the
ability to add or update this displayed infor.
Now this is what I want to do,
include an input box(readonly) that is also required to capture the
various dept(area) where the Billno d456 has been assigned.just one
input box that will show me that the same billNo d456 was also
assigned to not just the audit dept but also the finance &
humanresource dept. so the input box will just show the result
"audit, finance & Hresource.


You have really lost me here. I've tried reading it out loud, re-punctuating
it, and meditating on it <grin> and I still can't make any sense out of it.
Care to try again?

And you don't need to show us all the HTML. This is an ASP newsgroup, not an
HTML newsgroup :-)

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #4

Sorry if my question isn't clear.this is a simplified version

yes I am displaying a form that shows one record with
SELECT * FROM tblopgaCOm2 WHERE billNo = '" & Request.Form("B ILLNO") &
"' AND area LIKE 'AUDIT'"

The same "billNO"-d456 appears more than once but the "area" makes it
unique
On the same form or at least the same page i want to include another
Textbox that will capture or extract the other "area" where billNo d456
appears. something like
below,
SELECT area FROM tblopgaCOm2 WHERE billNo = '" &
Request.Form("B ILLNO") "

but not sure if I can include 2 select statements in one form & if so
how that is if this is the way to go??
hope you catch my drift better now??
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #5
iffy agbim wrote:
Sorry if my question isn't clear.this is a simplified version

yes I am displaying a form that shows one record with
SELECT * FROM tblopgaCOm2 WHERE billNo = '" &
Request.Form("B ILLNO") & "' AND area LIKE 'AUDIT'"
Again, the LIKE is not needed and may cause performance to suffer. Use "=".

The same "billNO"-d456 appears more than once but the "area" makes it
unique
On the same form or at least the same page i want to include another
Textbox that will capture or extract the other "area" where billNo
d456 appears. something like
below,
SELECT area FROM tblopgaCOm2 WHERE billNo = '" &
Request.Form("B ILLNO") "

but not sure if I can include 2 select statements in one form & if so
how that is if this is the way to go??
hope you catch my drift better now??

A little. You want to show a list of the areas to which a bill has been
assigned in a textbox. Why not a listbox?

Anyways, you can run two selects in your server-side code. It would look
like this (I will illustrate this with dynamic sql, but you would be better
off using saved parameter queries):

<%
dim cn, rs, , sSQL, sAreas
set cn=server.creat eobject("adodb. connection")
cn.open "<valid connection string>"
sSQL="Select area FROM tblopgaCOm2 WHERE billNo = '" & _
Request.Form("B ILLNO") & "'"
set rs=cn.execute(s SQL,,1)
sArea=rs.GetStr ing(1,,"","; ")
rs.close
sSQL = "SELECT <list of fields> FROM tblopgaCOm2 " & _
"WHERE billNo = '" & Request.Form("B ILLNO") & _
"' AND area = 'AUDIT'"
set rs=cn.execute(s SQL,,1)
etc.

The sArea variable will contain the list of areas. Just response.write that
into your read-only textbox

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #6

You can do one of two things.
1) Execute two seperate queries.
SQLQuery="SELEC T billno, area, upddate from tblopgaCOm2 WHERE
billNo...AND area='AUDIT'
then
SQLQuery="SELEC T billno, area, upddate from tblopgaCOm2 WHERE
billNo...AND NOT area='AUDIT'
2) Execute one query, and just check for which result
SQLQuery="SELEC T billno, area, upddate from tblopgaCOm2 WHERE
billNo='whateve r'"
if RS.Fields("area ")="AUDIT" then
'write out the audit stufff
else
'write out the other stuff
end if
"iffy agbim" <ia******@hotma il.com> wrote in message
news:%2******** *******@TK2MSFT NGP09.phx.gbl.. .

Sorry if my question isn't clear.this is a simplified version

yes I am displaying a form that shows one record with
SELECT * FROM tblopgaCOm2 WHERE billNo = '" & Request.Form("B ILLNO") &
"' AND area LIKE 'AUDIT'"

The same "billNO"-d456 appears more than once but the "area" makes it
unique
On the same form or at least the same page i want to include another
Textbox that will capture or extract the other "area" where billNo d456
appears. something like
below,
SELECT area FROM tblopgaCOm2 WHERE billNo = '" &
Request.Form("B ILLNO") "

but not sure if I can include 2 select statements in one form & if so
how that is if this is the way to go??
hope you catch my drift better now??
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 19 '05 #7
used your entire code Bob this is the error
I get.
ADODB.Recordset error '800a0bb9'

Arguments are of the wrong type, are out of acceptable range, or are in
conflict with one another.

/eiwp/audit3.asp, line 27
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #8
this is the exact line of code the error references

sArea=rs.GetStr ing(1,,"","; ")

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #9
iffy agbim wrote:
this is the exact line of code the error references

sArea=rs.GetStr ing(1,,"","; ")

My mistake. It should be:
sArea=rs.GetStr ing(2,,"","; ")

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3237
by: Eric Kincl | last post by:
Hello, its been a while since I posted/looked here... my normal email client doesn't handle newsgroups :( (ximian evolution) I was wondering how you stick a file into a database, and then retrive it again for the user with PHP/MySQL. I tried the following which apparently didnt work... Very quick overview of what I did... html
2
5345
by: Niyazi | last post by:
Hi, I have to retrieve a data from AS400 DB2 and after working with data I have to export into one of existing Excel file. I can connect into specific library in AS400 DB2 using AS400 Client-Access v5.2 program using (in VB.NET) ODBC driver (DSN Name …) . I can retrieve datam work on it using VB.NET and I can send into 'NEW' Excel file. My first problem starts here:
0
2960
by: Pato Secruza | last post by:
Hi everyone! I have a really frustrating error and need help. I’m trying to do a function that gets the properties and names of the fields in a MS Access database using ASP. I haven’t programmed in a while so I’m quite lost. Once I have the my database structure I will insert the corresponding fields from a web form but the database is huge and I want to be able to change the database and form without changing the ASP code all the
2
2471
by: Manish Naik | last post by:
Hi, Using ASP.Net, I want to store and retrive documents (Word, excel, etc) from SQL Server 2000 database. I have tried image type data field, but could not succed. Can any one help me please. Regards, Manish Naik
0
1346
by: rajesh nv | last post by:
I am not able to retrive the multi line data from database the newline character is Stored as square symbol in the database
1
1186
by: jaggu | last post by:
please help me out. I have designed a form with some text boxes. Now I want to add values to the text box which should get stored in the database(ACCESS) and later that can be retrived using buttons.
6
1535
by: kavithadevan | last post by:
Hi, I am trying to retriving some datas from the database.using submit button i am getting result but i inserted one submit image and i gave link to that image and then i run that script but its not working now.Can u tell me using link how to retrive the datas. here i pasted my script ---------------------search.php-------------- <form name="form1" method="get"> <table width="200" border="1">
1
1321
by: ohadm | last post by:
i've encountered a weired problem while retrieving date from access database: i'm using ASP VBscript\Jscript the data is stored using the "date()" command on VBscript code by someone else. when i'm trying to extract the code from the database using Jscript, i get full(unwanted) format(i.e:Day Mon dd 00:00:00 UTC+0000 Year) BUT when i do the same thing with VBscript- i get the date AS i entered it(i.e: dd/mm/yyyy) how can i convert the code...
2
1848
by: Marco Pais | last post by:
Hi there. I'm developing a small application that uses Web Services to access database and store data. At some point, I store some images, by inserting the absolute image path into a varchar field (SQL Server 2005). Images themselves are copied to that path on the server. To read the images, I just use this path. However, some workstations have to authenticate the server that path. To
0
9650
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10164
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7515
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6748
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.