Select Only The First Few Words Of A Record Field.
Say I have a field containig some text, for example: The quick brown fox jumped over the fence. How do I only show the first 4 words of the sentance, i.e: The quick brown fox...
View RepliesSay I have a field containig some text, for example: The quick brown fox jumped over the fence. How do I only show the first 4 words of the sentance, i.e: The quick brown fox...
View RepliesThis is my problem. I am adding to a table called Case the details of a case.Now the primary key for that, is an ID which is generated automatically by the DB.
I also have two relational tables related to the Case table, so I need to add records there. For this I need the case_id
just generated by the database when I added the case. What would be a good way to get that case_id?
I also need the case_id, because the interface to add info to the case table is spread across two tables, so when the user goes to the first page and "saves and continues" I want to store the case_id for the second interface page.If I select all the records from case, would I select the newest record first or would it be the last?
is there a way to select a row from a record set?
View Replies View RelatedOk here is what I'm trying to do. I want to grab a random record from a specific table. This is how I am doing it now:
x = 0
Set rs = Conn.Execute("SELECT Count(*) as total FROM [user] WHERE active = '1'")
If rs.EOF <> True then
total = rs("total")
End if
Randomize timer
randnum1 = int(rnd * total)
If randnum1 = 0 then
randnum1 = 1
End if
rs.close
set rs = nothing
Set rs = Conn.Execute("SELECT * FROM [user] WHERE id = '" & randnum1 & "' ")
Now that would work fine, BUT the id is a autonumber int of 1.
Now look at this example. Let's say I have 50 records, so I have the ID values of 1 through 50. Now I delete record number 46. So now my count goes up to 49. So the random number will pull up ANY number between 1 and 49, so if it pulls up 46 then BAAAM record can not be found.
There has to be an easier/more efficient way of getting a random record. I don't plan on deleting any records, but I just don't feel this is the best way of doing this.
I want to select a random record from a table within my Access database, however I am running into problems. When the page is executed, it always shows the same record. Code:
<%
Dim oConn, oRS, randNum
Randomize()
randNum = (CInt(1000 * Rnd) + 1) * -1
Set oConn=Server.CreateObject("ADODB.Connection")
Set oRS=Server.CreateObject("ADODB.recordset")
oConn.Provider="Microsoft.Jet.OLEDB.4.0"
oConn.Open Server.MapPath("temp.mdb")
oRS.Open "SELECT TOP 1 EMAIL_ADDRESS, r = Rnd(" & randNum & ") FROM TABLE1 ORDER BY r", oConn, adOpenStatic, adLockReadOnly
Response.Write oRS("EMAIL_ADDRESS")
oRS.close
oConn.close
Set oConn = nothing
Set oRS = nothing
%>
this gives the error: "No value given for one or more required parameters".
what i would really LOVE is for someone to fill in whatever required parameter im missing, but more important i would like to understand whats going on. there are people who go through life dumb and happy once something "works", but i need to understand how and why its working. even if this code did work, im confused with the SELECT statement (no, i dont have much SQL experience aside from basic queries). what is the "r = Rnd" line doing in the middle of the querie? how am i ordering by r?? also, i dont have an indexed, primary "ID" field in this databae. is that ok for this code to work?
cmdTemp.CommandText = "Select * From users"
cmdTemp.CommandType = 1
Set cmdTemp.ActiveConnection = DataConn
rstContacts.Open cmdTemp, , 1, 3
rstContacts.Move CLng(Request("Record"))
i only want this command to display from the users table the details
of the user that has the username (from the database) equal to the username of the person who has just logged in from my login form (uname input box) this code at the moment displays the first record, i dont want that.
I've got a database that has 5 numeric values for each record. I'm trying to figure out how to have the records sorted alphabetically, but highlight the highest value in the table for each column. So in other words, the table shows up with one record in each row, with a total of 6 columns (the name plus 5 columns). I want the highest value in each column to be emphasized.
So the final product would end up looking like the code at the bottom of this message.
I've pulled the records from the Access database and am able to sort them alphabetically and get the table to appear. What I was thinking is that at the top I'd define variables that correspond to the highest record for each column. Then in the table code I'd set the colour of each cell using an 'if then'.
So I have 3 specific questions:
- Is that the best way to do it? I don't want the page to take 20 minutes to load because I'm overloading the server.
- how would you set the variables at the top of the page?
- how would you write the if then in the middle of the table to change the background colour of the cell if that value (or values, in case there's a tie) is the highest of all the records? Code:
I try to execute the following:
Dim rsCars,mySQL,CAR_ID1,CAR_NAME
set rsCars=Server.CreateObject("ADODB.Recordset")
mySQL="select * from CAR WHERE (ENDING_DATE < Now() AND MAIL_SENT=0) AND CAR_STATUS=0;"
'mySQL="Update CAR SET MAIL_SENT=1 WHERE (ENDING_DATE < Now() AND MAIL_SENT=0) AND CAR_STATUS=0;"
rsCars.CursorType = 2
rsCars.LockType = 3
rsCars.Open mySQL,objConn
'set rsCars = objConn.Execute(mySQL)
But, it doesn't work both ways , and gives the following error:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
I have an ASP admin script where I'm adding records, and I have a
category that already has set name values hard-coded into a selct option
pulldown, but if the user wants to create a new category and not use the
select pulldown, the value will end up being " , newvalue" when posting
from this sequence of pulldown and input text box:
<select name="CategoryName">
<option selected></option>
<option value="first">first category</option>
<option value="second">second category</option>
</select>
<br>
New Category<br>
<input name="CategoryName" type="text" size="26"
maxlength="255">
What is the best way of not having that extra preceeding comma appear as
the value if the user chooses to add a brand new category?
i'm trying to figure out why i can not update a record if in the text box there is a ' anywhere in the field..
View Replies View RelatedI'm trying to delete some record information but only a set number of fields. when i run the following, it deletes all the record and not the field information in the given records:
set rs = server.CreateObject ("adodb.recordset")
StrSql = "DELETE field4, field5, field6," _
& " field7, field8, field9" _
& " FROM tblStock" _
& " WHERE field1 ='" & Request("loc") & "'" _
& " AND field2 ='" & Request("pdt") & "'" _
& " AND NumberOut =" & Request(" numberout")
'DEBUG ONLY
'Response.Write StrSql & "<br>"
'Response.End
cn.Execute StrSql
How would I get the max record + 1 to auto-populate in the GMVINC form field? I have a feeling that my query is not correct. Code:
View Replies View RelatedI do a SELECT * from table command in an ASP page to build a text file
out on our server, but the export is not to allow a field name rows of
records. The first thing I get is a row with all the field names. Why
do these come in if they are not part of the table records? How do I
eliminate this from being produced? Code:
I'm having problems retrieving all the values from a multiple selection field using the freeaspupload component.
I'm creating an online email app that uses the freeaspupload to add attachement functionality, which means the form encoding type is multipart/form-data. I've done something similar with the persits aspupload component, and had no problems with that, but the freeaspupload version seems to handle <select> fields slightly differently. Code:
I am trying to split a mgrgroup field to extract the MD codes. It correctly grabs the MD codes if all records in a mass update are updated, but if only one record in the loop is updated then it puts the last 5 digits of the mgr name in the MD field.
THIS IS THE CODE: ....
I am using the following code to split/join values in a multi-select field. It is combining all the values in All the records into one long string in each record in recordset.
Example: I have a recordset with 2 records. The 1st contains the split/joined values: Alan Smir, Jeff Karl The 2nd contains the value: Keith Robb
When it updates database, it will put Alan Smir, Jeff Karl, Keith Robb into each record in the recordset. Instead it should be putting Alan Smir, Jeff Karl into the 1st record
and Keith Robb into the 2nd record in the recordset.
Does anyone see what is wrong with the code ....
i'm new here and i'd like to ask if there's someone who knows how to compare date() function and date from database with date/time type inside select statement so i don't have to do if..then..else
View Replies View Relatedlet's say that I want to highlight some words or even a square of a table in yellow...how would i go about doing that? What code would work to do what I need?
View Replies View RelatedI'm having a problem in displaying a selected option from the drop down list in words. But after I selected an option, nothing is being displayed, I think the value can't be passed at all. Please let me know how to fix it.
<td align=center width=20%>Fruit:
<select name=""FruitName">
<%
" If not myRS.eof Then
while not myRS.eof
%>
<option value="<%=myRS.fields("ID")%>"<%If FId = myRS.fields("ID") Then response.write "selected"%>><%=myRS.fields("FName")%></option>
<%
myRS.MoveNext
wend
%>
</select>
<p>The fruit you have selected is <%=FruitName%></p>
I have a database field that is a memo type. I would like to be able to only display the first 50 words from the database. I would like for it to show ..... after about 50 words.
I am using <%=Content %>. How do I trim this field to show only 50 words and then ....?
I tried the following code:
Function LengthTrim(input, length)
If Len(input) > length Then
Return Left(input, length) + "..."
Else
Return input
End If
End Function
then <%= LengthTrim(Content, 50) %>
But it would not work. I got the following error message:
Microsoft VBScript runtime error '800a01f4'Variable is undefined: 'Return' .
I have data where first and last name are in one field. I need help
how to i separate first and last name in ASP.
the spaces between the words (in a textbox for example) are removed when i try to pass the value to another page for saving.
View Replies View RelatedI want to take a string like this:Code:
string = "THE RED GIGANTIC AND HUMONGOUS"
and retrieve only the words over a certain length or longer (let's say 5 characters), maintaining spaces between them- result:Code:
string = "GIGANTIC HUMONGOUS"
i am having trouble getting my REPLACE fn. to replace whole words only. basically, i'm running a 'spelling checker' fn. that uses the REPLACE fn. to find incorrect spellings and replace them. problem is, the fn. seems to replace all instances of a string, and not a whole word only as I intend it to be:
Code as follows:
StrInput = Request.Form("BKM_Search")
StrInput = LCase(StrInput) 'convert all to lowercase
StrInput = Trim(StrInput)'trim all empty space b4 & after string
StrCorrect = Replace(a_StrWrong, a_StrRight,1,1,1)
Let's say I want to replace the word "sea" with "ZZZ" only:
Example input: "Sean has some neat sea shells"
Example output: "ZZZn has some neat ZZZ shells"
I have to develop a spell checker from scratch using asp language. as i'm a newbie with asp, there are still a lot of things that i don't understand. How can I add new words to my list of dictionary sorted alpabetically?
Do i need to use the database for this function? Can anyone show me? or if anyone knows of any websites that i can refer to.
Let's say I have the following var:
Code:
strTemp="Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed"
and I am searching the string for another string 'amet', for example. How would I go about getting my page to output the word I search for and say 10 chars to the left and 10 to the right? So, in this case, I'd like to be be able to search the string with any
other string ['amet' for example] and have it output this:
Code:
...dolor sit amet, consecte...
wondering if its possible to have some kind of searched word highlight! IE. every thing it throws up in return of search it will highlight why it has brought it up! so if search "a" all "a" in return results would be highlighted.
View Replies View Relatedis it possible (i heard u can replace) to filter out bad words using regexp? I'm using Replace() but it sucks without ALOT of extra code... but using regexp it seems better, with ignorecase, etc.
How would I do it? O, here's the way it is now:
<%= Decode(ChkBadWrds("Comment")))%>
How would I do something similar using regexp?
how can i count how many words have i written in a text
area?Like taking an example ... i am writing in this textarea
of microsoft usergroup. and say in total i have written 50
words .. how can find out this information?
I retrieved some data from the database and put it in a textbox but the words after the blank sapace cannot be shown, why is that?
Name = rs("requestor") 'where the name is "Sam Siew"
<TD><INPUT TYPE=TEXT Name=requestor size=12 Value=<%=Name%>></TD>
In the text box, it only show "Sam".
how to capitalise all words in a string that are seperated by spaces. The string is variable and not the same every time hence I cant use the Ucase function as I wont know the exact position of the start of each word.
View Replies View RelatedI would like to have a text box where people can type a word they want and then click on a button to get the description of that word.The way I see it working is if the word they entered in the box is in my database a page will display the meaning corresponding to the word in the database. However if it is not then it will display a message telling them that.
View Replies View Related