How Can I Refer To A Query Which Links Different Records In One Table In ASP

I am new to ASP and I want to use a query which links one record in a table to another record in the same table to display a list of values. The query lists the names of all managers (the managers staff no is held in the reports_to field of an employee)

Set rs=Server.CreateObject("ADODB.Recordset")

rs.Open "SELECT DISTINCT p2.Surname + ', ' + p2.[First name] AS Expr1
FROM People p1 INNER JOIN People p2 ON p1.reports_to = p2.[Staff no] WHERE (p1.[Staff no] IS NOT NULL)",con,3,3
while not rs.EOF
%>
<option value="<%=rs("p2.surname")%></option>
<%
rs.MoveNext
wend
rs.Close

However it doesn't like the alias (p2). Is it possible to return a list from this type of query?

View Replies


ADVERTISEMENT

Access Table Links To SQL And Web Connection

I have an access database residing on one server that contains necessary data for this application, have sql database that also contains necessary data and resides on another server.

For two access databases I would just "link" the tables and be done with it, but when attempting to do this with ODBC connection to the SQL server I get

Microsoft JET Database Engine error '80004005'

ODBC--connection to 'databasename' failed. Code:

View Replies View Related

Systematic Updating Of Records Depending On Amount Of Records In Another Table

The problem concerns 2 tables, cart_products and cart_shoppingcart.

Cart_products contains all the product data (eg, prices, product's key name, etc), but most importantly, it contains the quantity of stock (prod_quantity) for each item.

cart_shoppingcart contains all of the user's items in their shoppingcart, including those that are part of an (customer) order; these have the order_number to differentiate from those that aren't in any order (their Order_number is 'no_order', the others have the order number).

Now, what I want to do is this:

For every item in the order (ie, every entry in cart_shoppingcart that matches the username and order number), take the quantity (x) the customer is ordering, then take the quantity of stock remaining (y), then subtract x from y to create the new stock level (z) and update the appropriate record in cart_products with z (all this with SQl preferably).

I was thinking of using a Do while loop, but realised that it wouldn't work as I'd have to use several SQL statements and then I'd run into a problem the minute ASP reads "objrec.movenext".

View Replies View Related

How To Transfer Records From One Table Of A Database To Another Table In Another Data

I have aproblem to transfer a data from table x to table y based on id. Its mean when 2 table have same id all data table x must move to table y. I don't know which command need to use is it insert into or update?

<%
Dim conn
Dim rs
Dim MYSQL,MYSQL2

Set conn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")
Set cmd = Server.CreateObject("ADODB.Recordset")
conn.ConnectionString = "DSN=prmm;UID=administrator;pwd=sa"
conn.Open

startdate=request("tarikh1")
enddate=request("tarikh2")

MYSQL = "SELECT * FROM table_x where paymentdate between '" & tarikh1 & "' and '" & tarikh2 & "'"
rs.open MYSQL,conn ....

View Replies View Related

Display Records From SQL Table

I'm trying to display records from a table in a sql database.The problem is, every month a new table is created, so I don't know what the name of that table is going to be.
It there a way that I can make sure the sql only reads from the latest created table?

View Replies View Related

Pulling Records For A Table

I've created a form where the user should be able to select an option, then a second list will be populated based on that selection. The next part is where I am running into trouble.

The user can also select a time window which can limit their search, if they so choose. Code:

View Replies View Related

Count Records In A Table

I know I've asked this before, and other people have too. But when I use that igrep search thing, almost all of the search results are scambled (when you clikc on a search result, its just a scambled up thread).So I'll ask again, because I have forgotten. I know that to count the entries in a recordset, you usethe following code...Code:

RS.RecordCount

But I know that you need something else, something about a client-side pointer? Without it Im just receiving -1 each time.

View Replies View Related

Displaying Records From Table

Say i have 100 rows in a table and i make a query:"Select * from table", i will get all the 100 rows displayed, but what i want to do is to display 20rows in a page and then have 'Next' and 'Previous' links to navigate through the records 20 by 20. This is in fact exactly as in this forum where only 20 posts are displayed sorted by most recent ones and so on.

View Replies View Related

SQL Table Returns All Records

I have this sql query

SQL="SELECT title,body FROM cinema WHERE date_end > #" &date()& "#"

cinema is a table which contains announcements about cinema title,body (txt fields)are columns of my a table called cinema date_end(DATE/Time Field): is a date (DD/MM/YYYY, short format).This date shows when the announcements expire .But SQL returns all the announcements that the table contains even those that have already expired. Why??I cant find any mistake.

View Replies View Related

Count Records In A Different Table

Trying to duplicate the functionality found on this page:

I have a new table i've created that stores peoples search queries:

INDEX, SEARCH, COOKIEID, CID, SUCCESS, DATE

I have a seperate table that stores my product data, including the keywords. My search function uses a LIKE %%examplekeyword to match searchs to the DESCRIP column in this inventory table.

How can I make one SQL query to display the same results as on the the example page? It's easy enough to SELECT the results, but how do I do a count of how many instances of that search word exist, inside the same SQL statement?

View Replies View Related

Refer To Another Page

How do I refer to another asp page from within the exisitng page? ASP1.asp has all the database connections. ASP2.asp need to refer to ASP1.asp for the database connections.

View Replies View Related

Refer To A Function

I have multiple websites on single IIS. I have a function (in a seperate aspx.vb file) that I want to use for all the default pages on these sites. How do I 'call' this function' from the aspx files without copying the files into each 'bin' folders? what is the syntax for the code.

View Replies View Related

Retreiving The Number Of Records In A Table?

i need to go through a list of items and check to see if items on list 1 are on list 2 and vise-versa. so im going to look at item 1 on list 1, and go through all the items on list 2. if i find a match, ill update the record on list 1, if i dont find a match ill update the record on list 2.

im going to need a nested loop. in c++ i know how i could do this, but im not sure as how to do it in vbs/asp. can you do for each "record" in "myrecordset"? or do i have to get the number of records in the table and run the loop that many times? which would be eaister?

View Replies View Related

Problem With Adding Records To A Table

There is something wrong with the adding code. It will add sometimes. It's a large database where I have to add records to multiple tables.

The products table doesn't work correctly. Maybe there's a typo somewhere that I don't notice. Please look at the bolded part of my code and see if you can catch something. Code:

View Replies View Related

Query Database Table

I have this code that retrieves the logged in users info. What I also need it to do is to display other records in the database that match the logged in users custnumber. Code:

View Replies View Related

Create Table Query

In the same way that you can create and alter permanent tables in Access 2000 using SQL in ASP ( CREATE TABLE <tablename> col_1(col_1 datatype), col_2(col_2 datatype....Col_n(col_n datatype)) is there any way to do this for Queries?

View Replies View Related

Why Cant I Return Any Records From Query..?

When ever i try to search for a number in a form to bring back the customers info i get no result returned! However the customer exsist in the database. What could be the problem?? Code:

View Replies View Related

How Can I Get Duplicate Records Through Sql Query

how can i get duplicate records through a sql query i am using MS Access database.

View Replies View Related

Edit Multiple Records In A Single Table

I am using a db to hold student data records. I currently display them in a roster based on their affiliation with a certain class. To edit a record I need to click the name of an individual, it opens an edit page, I make the changes, hit submit and return to the roster.

This is pretty standard stuff. What I would like to do is change one field of every record without opening each record individually. The idea comes from my Fantasy Fball league roster:

McNabb, Donovan QB PHI ActiveReserve
Droughns, Reuben RB DEN ActiveReserve
Johnson, Rudi RB CIN PIT ActiveReserve
...etc...

Where the example above says "ActiveReserve" is a pull down menu that lets me change who is playing week to week. I can then change each record, hit submit one time, and update the db. So how do they do it?

View Replies View Related

Insert Multiple Records Into The One Table At The Same Time

Does anyone know how to insert multiple records in the same table at the same time. This is what I have. I have a form with 6 fields and they are name prod1 through to prod 6. The table is called related products.

Basically this table is related to the main table called prod_parent. tried looking on google and couldn't find anything.

View Replies View Related

How To Update Multiple Records Into A Single Table

I already have this piece of code that inserts multiple rows of data into a single table at once. Code:

View Replies View Related

Count And Display Number Of Records In Table

how can i Count and display number of records in table?

View Replies View Related

Creating XL Sheet From Query Table In ASP

Using regular VB ASP (not .net) and calling an Access database using ODBC, I've generated a recordset based a query... (no big whoop, obviously)

Now I want to be able to open a new XL spreadsheet (client side - we're assuming user has XL) and export that table to it. I've seen some posts about DoCmd.TransferSpreadsheet, and CreateObject("excel.application")... I've never actually used them before, so I don't know where to start.

I'd like to have a link on the page with the table to "export to XL"... and then have it open XL (client side) with that table in a spreadsheet.

View Replies View Related

Check Table/query Exist

Is there a method where by I could check for a certain table or query
exist in my access database file before I made query to it??

View Replies View Related

Table Does Not Exist Error In AD Query?

this runs perfectly as a .vbs but I'd like to convert it to an ASP... any
ideas? Code:

View Replies View Related

Insertion In Temporary Table From Query!

i have written a stored procedure. depending upon different parameters, query is prepared as string and executed through exec() function. it returns a certain number of rows. stored procedure also contains a temporary table. the question is this how can i insert the rows returned by the query in to temporary table?

View Replies View Related

Asp Database Pull From A Query Not A Table?

it possible to pull the information from a query located inside the .mdb database already, instead of pulling the information from the tables ?

View Replies View Related

Fill Table With Database Query

I want to retrieve a large number of rows from my database (Select SomeColumns from myDatabase)and then to fill a table with the retrieved data. What can i do?

View Replies View Related

Trying To Put An Asp Query Generated Table Into InnerHTML

I'm trying to figure out how to display a query generated table in a div through an "innerHTML=...." - not only can I not to get the table to generate more than one row, I can't populate the column/cells with any data from the query -

The asp's/vb script (which works fine as a standalone asp page) is: Code:

View Replies View Related

Use Array To Hold Or Refer To Recordsets?

I want to use an array to either refer to a recordset or hold the recordset. For example, I have this:

dim rows(5)
rows(0)= rs_manager_0.recordcount
rows(1)=rs_manager_1.recordcount
rows(2)=rs_manager_2.recordcount
rows(3)=rs_manager_3.recordcount
rows(4)=rs_manager_4.recordcount

Can I change it to this:

recordset_names(5)
recordset_names(0)=rs_manager_0
recordset_names(1)=rs_manager_1
recordset_names(2)=rs_manager_2
recordset_names(3)=rs_manager_3
recordset_names(4)=rs_manager_4

for i = 0 to ubound(recordset_names)response.write (recordset_names(i).recordcount)next

The errors is: Object doesn't support this property or method: 'recordcount'

And if I put quotes in the array dim :

recordset_names(0)="rs_manager_0"

The error is: Object required: 'rs_manager_0'

Its not that I'm too lazy to write out the 4 recordset names each time. Th eproblem is that the number of recorsets is variable and there are a lot of tehm , hence I want to refer to the with some simple looping script.

View Replies View Related

How Do I Refer To Inetpub In An Include File??

I'm attempting to move my database to my site so I can introduce some ASP and ADO. My database is now located in a directory named 'database' which is at the same level as wwwroot.

Could someone please tell me how I change the following line in my Include.asp file to compensate for this? Is there a system variable I shouldcan use?

"Data Source=C:/Inetpub/database/Database1.mdb"

View Replies View Related

Crosstable Query Returns Too Many Records

I'm writing a work schedule application in ASP, and I am using an Access 2000 DB with the following tables:

WorkSchedule
--------------------------
| ID | Date | EmployeeID |
| .
| .
| .

Employees
---------------------
| EmployeeID | Name |
| .
| .
| .

Status
----------------------------------------------------
| StatusID | DateFrom | DateTo | EmployeeID | Type |
| .
| .
| .

I need to retrieve a list of employees, which are not scheduled for work between the given dates and which have no status (sick leave, maternity leave etc). The object is to see which employees are available for scheduling on the different dates.

The resulting table/recordset should contain one record per date per available employee (see example below). Code:

View Replies View Related

Query All Records After Today's Date

I've got an access database with a field containing dates (each saturday of the year), set up as a date field. In my code i need to write the SQL to select all records that have a date after todays date.

I've got the rest of the code but it's the where clause i'm stuck on. Something like, WHERE mydatefield is after (could i use >?) currentdate. Not really sure how ot go about doing this... I'm using ASP, is there a way the SQL can get the current date, or would i need to generate it and store as a variable first? Also, don't know what type of quotes i would need to use " or ' or + etc.

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved