Outline ·
[ Standard ] ·
Linear+
updating database [ASP], another prob...SQL statement..pls help!!
|
TSgracenalec
|
Feb 5 2006, 05:02 PM, updated 20y ago
|
Getting Started

|
<% Dim adoCon 'Holds the Database Connection Object Dim rsUpdateEntry 'Holds the recordset for the record to be updated Dim strSQL 'Holds the SQL query for the database Dim lngRecordNo 'Holds the record number to be updated
lngRecordNo = CLng(Request.Form("User_ID")) Set adoCon = Server.CreateObject("ADODB.Connection") Set rsUpdateEntry = Server.CreateObject("ADODB.Recordset")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("forum.mdb")
strSQL = "SELECT * FROM profile WHERE User_ID = '" & lngRecordNo & "'" rsUpdateEntry.Open strSQL, adoCon rsUpdateEntry.CursorType = 2 rsUpdateEntry.LockType = 3
rsUpdateEntry.Fields("Name") = Request.Form("name") rsUpdateEntry.Update
rsUpdateEntry.Close Set rsUpdateEntry = Nothing Set adoCon = Nothing
'Return to the update select page incase another record needs deleting Response.Redirect "update_select.asp" %>
i'm having prob wif this...i'm trying to update my database..juz like when u click 'edit profile' in lowyat forum. after chging the details in a textbox and clicking a button to submit the chges, chges will b made in de datbase..how can i do tat?
Script error detected at line 14. Source line: rsUpdateEntry.Open strSQL, adoCon Description: [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
pls help
This post has been edited by gracenalec: Feb 6 2006, 09:30 PM
|
|
|
|
|
|
SincerePrayer
|
Feb 5 2006, 08:37 PM
|
love to pray
|
gracenalec, Instead of select the record out and update it, you may want to try to issue an SQL command to directly update the record. This approach will increase the performance for your server. CODE strSQL = "UPDATE profile " strSQL = strSQL & "SET [Name] = '" & Replace(Request.Form("name"), "'", "''") & "' " strSQL = strSQL & "WHERE User_ID = '" & lngRecordNo & "'"
Happy Coding
|
|
|
|
|
|
sinister
|
Feb 6 2006, 01:13 PM
|
|
yup..
i wouldn't recommend u use dat way, better to use SQL command, it's faster and more efficient..
Better learn ur INSERT,UPDATE sql statement.
|
|
|
|
|
|
TSgracenalec
|
Feb 6 2006, 09:27 PM
|
Getting Started

|
okok..thx a lots guys..my problem is solved unfortunately i have another problem...wat is my SQL statement when i wanna use the LIKE statement. I did this: SQL= "SELECT * FROM posts WHERE message LIKE" &% search % it keeps on giving me error..i wonder if this is the correct SQL statement used in asp..btw...search is actually a variable...wat i'm trying to do is accept user's input from a textbox and store in to variable-search. pls correct me..thxx
|
|
|
|
|
|
lmcckl
|
Feb 6 2006, 09:29 PM
|
Getting Started

|
where is line 14  anyway, likely the problem have something to do with null value
|
|
|
|
|
|
TSgracenalec
|
Feb 6 2006, 09:52 PM
|
Getting Started

|
yea...that error is done dy..but the sql statement of the prob i stated above isn't done  pls help
|
|
|
|
|
|
SincerePrayer
|
Feb 6 2006, 10:13 PM
|
love to pray
|
gracenalec, You may want to try the following code CODE strSQL = "SELECT * FROM posts WHERE message LIKE ''%" & search & "%''"
Happy Coding
|
|
|
|
|
|
sinister
|
Feb 7 2006, 09:54 AM
|
|
grace.. could u publish ur not working code so dat we can have a look
|
|
|
|
|
|
one.good.guy
|
Feb 8 2006, 02:00 PM
|
|
try this:
strSQL = "SELECT * FROM posts WHERE message LIKE '%" & search & "%' "
I think there's one too many apostrophe ' in the code given by sincereprayer.
This post has been edited by one.good.guy: Feb 8 2006, 02:02 PM
|
|
|
|
|
|
lmcckl
|
Feb 11 2006, 04:27 PM
|
Getting Started

|
User_ID field is a integer field or string field ? if it a integer field pls try this CODE SELECT * FROM profile WHERE User_ID = " & lngRecordNo
btw, i just remove the single quote This post has been edited by lmcckl: Feb 11 2006, 04:28 PM
|
|
|
|
|
|
lmcckl
|
Feb 11 2006, 04:34 PM
|
Getting Started

|
QUOTE(gracenalec @ Feb 6 2006, 09:27 PM) okok..thx a lots guys..my problem is solved unfortunately i have another problem...wat is my SQL statement when i wanna use the LIKE statement. I did this: SQL= "SELECT * FROM posts WHERE message LIKE" &% search % it keeps on giving me error..i wonder if this is the correct SQL statement used in asp..btw...search is actually a variable...wat i'm trying to do is accept user's input from a textbox and store in to variable-search. pls correct me..thxx MS access have diffrent syntax for like statement. if remember it correctly it is something like this CODE SELECT * FORM posts WHERE message LIKE #search# Please try the query with ms access if posible and ms access help file got example that might help you solve your problem
|
|
|
|
|
|
shinchan^^
|
Feb 13 2006, 09:11 AM
|
|
oh ya miscosft access use different format
|
|
|
|
|