Ref Database Field Name With Variable
I have an asp page that has a function that connects to an Access database.
I am using Javascript. Is there any way to reference the field name in the
database through a variable in a sql statement? Code:
I have an asp page that has a function that connects to an Access database.
I am using Javascript. Is there any way to reference the field name in the
database through a variable in a sql statement? Code:
Usually, we can get data from table
by using rst("userid") because we know the column name
userid. Now, I have a variable to hold the column name. I
want to get data value like this rst(var1). However, I got
an error message.
I've declared a variable for the current date and want to use the UPDATE function to update the date field in a single record.
UPDATE lms_users Set leaver_date ="&MakeDate" WHERE user_id="473"
I know I have the date format in the variable as if I response.write it to the screen is displays correctly (28/08/2004). I must be doing something really silly, but can't see it.
i have two asp pages, one collecting value in a for the other displaying those values.
Normal non-hidden text fields are displaying properly. But my hidden field is not. The hidden field is made up of 3 other text fields and joins them together. This page collects and sends values (i only included the item in question) Code:
I get a "data type mismatch error". I assume it is because this is a number, but I don't know what to change.
<%
dim cnStr
dim rcSet
dim frmSSN
dim sqlStr
'store form input into variables
frmSSN = Request.Form("SSN")
'create connection and recordset objects
Set cnStr = Server.CreateObject("ADODB.Connection")
Set rcSet = Server.CreateObject("ADODB.Recordset")
' defining database connection (connectionstring2.inc)
cnStr.ConnectionString = path
cnStr.Provider = provider
cnStr.open
%>
<%
SQL_query = "SELECT * FROM Orders WHERE Driver = '" & frmSSN & "'"
Set RS = cnStr.Execute(SQL_query)
WHILE NOT RS.EOF
%>
I'm trying to upload the entire field for every recordset to . How could I do this? Here's what I got so far.
<!--#include file="searchconn.asp"-->
<%
UPDATE SearchTable SET SearchTable.newscontent = " ";
%>
I have an access database with year designations for field names, such 2005 2004 2003 ... and data corresponding thereto. I can formulate a query in MSAccess and it works just fine. However, I am trying to create a web page that will create a database
connection and use SQL to create a recordset(s) which I can then manipulate in vbScript.
The problem seems to be structuring a query that will work in
vbScript. I have tried several combinations:
rs2.Open "SELECT 2005,2004,2003 FROM Table", conn, adOpenStatic, adLockOptimistic
rs2.Open "SELECT '2005','2004','2003' FROM Table", conn, adOpenStatic, adLockOptimistic
rs2.Open "SELECT "2005","2004","2003" FROM Table", conn, adOpenStatic, adLockOptimistic
but none of these will extract data.
I have also tried casting these numbers to strings in a string variable, but still no success.
Is there some naming convention I am violating by simply using year designations as field names or is there a problem with vbScript?
I pass a table name into my program dynamically. I could display the data by looping through the object.Fields for both the field name and the field data using object.GetRows.
What I have not figured out is if there is a way to figure out from the Fields what type of field (ie. Numeric, Text) it is.
Certainly I could check the actual data once it is read, but is there a way to figure out the field type without doing that? Perhaps an object property of a recordset that I am not familiar with?
I have a "csv file" as a database.
The 1st row contains the field names:
Orion.Accounts.AccountName,Orion.Accounts.Address1
the code I use normally works:
<%=rs("Orion.Accounts.AccountName")%>
Although in this case is doesn't because the fieldnames contain full stops.
how to modify this line:
<%=rs("Orion.Accounts.AccountName")%>
what i am trying to do is when the database field is empty to not display the box (table) that is in my css file, whereas when there's something in the field i would like the box to display!!! So i'm basically trying to get a 'when field empy, do nothing!!! my code at present generates the box no matter whether the field is full or not!!! Code:
View Replies View RelatedI'm having a spot of trouble trying to update fields in a access database using asp. I can delete and add fields thru the asp page but when i attempt to modify the fields i get a page not found error message. Code:
View Replies View Relatedim trying to increase the value of an id key in my database by 1 each time i add a new record. is ther anyway i can do it using ASP?
View Replies View RelatedI want to search 2 of my database fields (title and description) for search terms entered in a form. I can do a 'LIKE' but how do I cover searching for each word in the string that has been submitted? For example, if someone searches for 'World Cup Final', I want to search both database fields for 'world', 'cup' and 'final'.
View Replies View RelatedI have a form that inserts a student's course choices into an Access db. The student can choose from 4 options in a day. From a drop down box that is populated from the db.
Each course has a field called count1, count2, count3 and count4 which are the class sizes for those sessions. When they choose a session, I have a bit of ASP that takes '1' away from the count.
However, I need to validate the form when it is submitted so that if course = 0 a message pops up to say the course in that session is full. At the moment, the drop down boxes are populated by SQL that says only show if count>0 but if a lot of students load the page at the same time they can all subscribe to it - so I am getting -4 in some sessions. I need to check whether the course in that option is full i.e. '0' when the form is validated and then for it to tell them that that particular session is full.
I am trying to take a name that is in a database field and rearrange it to place it in a session variable. For example:
Database Field:
SMITH, JOHN
What I would like to see:
JOHN SMITH
Instead of - Welcome SMITH, JOHN
I would prefer - Welcome JOHN SMITH
Can this be done when requesting a form variable or does it have to be done when viewing the recordset variable.
Does anyone know how to update a session variable to the database.
I can get the session variable to appear on the screen but I can't seem to get it to be send to the database using a form and hidden fields. Does anyone know how to go about this. What do I need to do to maken it work. I'm using ASP/ VBScript & an access database.
Is there any way you can put a variable in the values in an update command?
If oRS("n4") <> 0 then
Response.Write ("<tr>")
Response.Write ("<td>4</td>")
Dim qn4
qn4 = oRS("n4")*intQuantity
strsql = "INSERT INTO report (q1) VALUES (qn4)"
Set oRS2 = oConn.Execute(strSQL)
Response.Write ("<td>Meter box, meter and test block</td>")
Response.Write "<td>" & oRS("n4")*intQuantity & "</td></tr>"
end If
I am trying to determine if a field in a database is empty or not. The code I have is this....
(before this I have code that opens up the database, gets the data from the table. the var "content" holds the data if any from the database.)
if content = "" then
alert1 = "content field is empty"
else
alert1 = "content field contains text"
end if
This doesn't seem to work. I also tried...
if (content) then
alert1 = "content field is empty"
else
alert1 = "content field contains text"
end if
No luck yet. Any ideas?
I'm trying to post a value from a form field into a database field of type Date/Time formated to short date.
Even though the value from the form comes in short date style ie 19/06/2004 I'm getting a type mismatch error
I have an ASP variable called IRNvar:
If IRNvar(0,num) = "True" then
IRNvar(0,num) = 1
else
IRNvar(0,num) = 0
end if
In my sql database I have a True/False field called VariantFlag which is a bit data type. The IRNvar value is numeric. I am trying to insert the 1 or 0 into the database so that the field shows true or false accordingly but I get a 'Type Mismatch' error. Here's the insert statement:
SQL = "INSERT INTO Documents (CNID, DocumentPrefix, DocCategory, DocumentName, VariantFlag, PartNo, PartDesc, NewIssue, StatusID) VALUES ('" & CNID & "', '" & IRNprefix & "', '" & IRNcat & "', '" & IRNnumber & "', " & IRNvar & ", '" & PartNum & "', '" & IRNDesc(0,num) & "', 'A', '5')"
Is there a way to convert the number to the right data type? Am I doing something wrong? I'm quite new to all this so it's probably something silly.
I have an access database with lots of fields including a memo field called
'priecinfo'.
Everything works well, lots of data is written, but in one particular
situation, I can't get the field 'priceinfo' to write out:
1) the code below works properly except that the field 'priceinfo' doesn't
get written - replace it with any other field and it works. Code:
I have the following line of code that is part of a form that displays a record from a database;
<textarea name="name" cols="60" rows="20" value="<% =rscms_example("body") %>" </textarea>
Could you please tell me where I am going wrong on it? I know its probably very simple, but I am terrible at forms anyway.
My question is this: how do I get a value from a listbox to assign to a variable (elementary I know)? Code:
View Replies View RelatedI need to validate an item number from a form field against a MS SQL database
I am using a 2 page process to print barcodes from an entered item number on page 1 and need to only use valid item numbers from the database. If they enter a wrong number I want to give them a page telling them of the error.
I have 32 fields on page 1 to enter 32 items.(one for every label on the second page that contains the barcodes. Here is the connection to the database that I am using for the barcode.(Column IMLITM contains the item numbers) Code:
Trying to update 2 fields. my database is read only..
Microsoft JET Database Engine error '80040e09'
Cannot update. Database or object is read-only.
/sendd.asp, line 16
this is line 16: rsAddComments.AddNew
is this something to do with my server directory permissions?
code .....
I currently have a web page that pulls in job vacancies from a search form all written in asp and the database is in access. I will be placing an extra field which will say "apply now" and on selecting this you will be taken to a new page where you can fill in your details and email them to the employer.
My problem is I need to know how to get a field in the form that will automatically fill in the title of the vacancy being applied for from the database.
I am pulling legislation information and expiry dates from an access database and posting to the web. The expiry dates in access are formatted as Month Day, Year (EG.. January 1, 2006) But when they are pulled from the database to the web, they come out as 01/01/06. I know that the format we have in access is simply a mask, however we require that format be carried through.
This is likely a simple solution, however I am new to ASP and can't seem to locate any information on this. I have searched the forum for related info on this but can't find anything that relates to my specific situation.
Here's the code we are using so far...
Code:
<%
Do While NOT Recordset.Eof 'i.e. carry on looping through while there are records
Response.write "<tr><td>"'open row and first cell
Response.write Recordset("Legislation")
Response.write "</td>"'close first cell
Response.write "<td>"'open second cell
Response.write Recordset("Repealed")
Response.write " "
Response.write Recordset("Expiry_Date")
Response.write "</td></tr>" 'close row
Recordset.MoveNext 'move on to the next record
Loop
%>
I have also found and implemented the following code:
Code:
dt=recordset("Expiry_date")
dt=Month(dt)&"/"&day(dt)&"/"&year(dt)
response.write(dt)
This lets me change the positions of the numbers, but I can't figure out how to make it display the full month name and full year.
Is it possible to insert more than 2 checkbox values into 1 field in the SQL database?
I have 5 checkboxes; I would like to insert them all into 1 column in the SQL DB.
If I insert more than 2, it gives an error.
How to search a database field from form input? is it easy to do i like to have a html form from an html page that will call an asp page to do db search, if user enter a zipcode that match in the database it will pull all the infomation from both talbes and display on the screen
i have 2 tables related to each other
contact table
id, fname, lastname, contactid, email
zip table
id, zip, contactid, city
How to search a database field from form input? is it easy to do i like to have a html form from an html page that will call an asp page to do db search, if user enter a zipcode that match in the database it will pull all the infomation from both talbes and display on the screen
i have 2 tables related to each other:
contact table id, fname, lastname, contactid, email
zip table
id, zip, contactid, city
I have been provided with a DSN, user name and password for one of my
clients sites.
I'm not an ASP developer and need to view all the contents of this database.
I usually work in PHP but only have ASP available on this server.
I want to open the database and simply output all the contents into a HTML
page.
I would like to create a page of hyperlinks that are constructed from the contents of a database field. When the user clicks the link they are taken to a page that will display all fields from that particular record.
I already have the page structures in place. There are two pages, one with the links and the other to display the record. Code:
I am working on a site with MS Access and ASP that needs to have data selected from a listbox, populate several span fields. I can do it with JavaScript but the array data is hard coded, I want the data brought in dynamically from an Access database. Here is my JavaScript code:
View Replies View Related