By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,660 Members | 1,593 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,660 IT Pros & Developers. It's quick & easy.

syntax errpr near parenthesis

syedshaffee
P: 91
this is my code
Expand|Select|Wrap|Line Numbers
  1. dim i
  2. dim checkboxValue
  3. dim TextBoxValue
  4.  
  5. dim Count
  6. dim Count1
  7. dim postion
  8. dim postion1
  9. position=0
  10. postion1=0
  11. i=0
  12. Checkbox1= Request.Form("same")
  13. strdate=Request.Form("Date")
  14. a=Split(strdate ,",")
  15. b=Split(Checkbox1,",") 
  16. if strdate<>"" and Checkbox1<>"" then
  17. TextBoxValue=UBound(a)
  18. checkboxValue=UBound(b)
  19. 'Response.Write(TextBoxValue)
  20. if TextBoxValue  > checkboxValue then
  21. for i=0 to TextBoxValue
  22. Set objRIMSConn1 = Server.CreateObject("ADODB.Connection")
  23.     objRIMSConn1.Open RIMS_CONNECT
  24.     objRIMSConn1.Execute "Insert into Eot_returned(Asset_id,Date) values("+b(i)+",'"+a(i)+"');"
  25. next
  26. objRIMSConn1.Close
  27.     Set objRIMSConn1 = nothin
  28.     else
  29.     for i=0 to checkboxValue
  30. Set objRIMSConn1 = Server.CreateObject("ADODB.Connection")
  31.     objRIMSConn1.Open RIMS_CONNECT
  32.     objRIMSConn1.Execute "Insert into Eot_returned(Asset_id,Date) values(" +b(i)+ "," +a(i)+ ")"
  33. next
  34. end if
  35.  
  36.     Response.Write("<script language='javascript' type='text/javascript'> alert('The value hass been Inserted'); </script>")
  37.      else
  38.     Response.Write("<script language='javascript' type='text/javascript'> alert('Do you want to return any asset'); </script>")
  39. end if
Erro:Near ")" please an u people help me???????????
Attached Files
File Type: txt Code.txt (1.1 KB, 290 views)
Jan 26 '12 #1
Share this Question
Share on Google+
18 Replies


Rabbit
Expert Mod 10K+
P: 12,370
You've only defined one field to insert into but you include two values.
Jan 26 '12 #2

syedshaffee
P: 91
yes i can but the problem is in two its giving an error
Jan 26 '12 #3

Rabbit
Expert Mod 10K+
P: 12,370
I have no idea what you're saying. I'm saying that you can't specify two values when you only specify one column.
Jan 26 '12 #4

P: 16
you have no space between ")" and "values"
if you want any help, it's better to post the full error message.
you can get the error message with
response.write err.description
Jan 26 '12 #5

syedshaffee
P: 91
thnaks u guys and mlutinett i will post the full error message
Jan 26 '12 #6

jhardman
Expert 2.5K+
P: 3,405
Rabbit is definitely right: the insert statement has the wrong number of fields.
If you were inserting into just one field the command would look like this:
Expand|Select|Wrap|Line Numbers
  1. insert into eot_returned (asset_id) values (4)
but if you were inserting into two different fields, the command would look like this:
Expand|Select|Wrap|Line Numbers
  1. insert into eot_returned (asset_id, asset_name) values (4, 'John')
If you were trying to insert into one field but two different records, you would need two different insert statements
Expand|Select|Wrap|Line Numbers
  1. insert into eot_returned (asset_id) values (4);
  2. insert into eot_returned (asset_id) values (5)
the way you have it is definitely wrong, but I can't tell which you are trying to do.

Jared
Jan 26 '12 #7

syedshaffee
P: 91
jhardman i have changed the code and still it is giving me an error the following is the error:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near ')'.
, line 876
Jan 27 '12 #8

syedshaffee
P: 91
OKAY now the values are going to the database but its still displaying the same page
Jan 27 '12 #9

Rabbit
Expert Mod 10K+
P: 12,370
What do you mean it displays the same page?
Jan 27 '12 #10

syedshaffee
P: 91
the error page in asp
syedshaffee
re: syntax errpr near parenthesis
jhardman i have changed the code and still it is giving me an error the following is the error:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near ')'.
but the date time column in sql is like 1/01/1900 for each column
Jan 28 '12 #11

Rabbit
Expert Mod 10K+
P: 12,370
You said the data was going into the database, it shouldn't be giving you an error message if it was. Are you sure the data is getting there?
Jan 28 '12 #12

syedshaffee
P: 91
yes i checked it even i'm wondering how???? is this possible
Jan 28 '12 #13

Rabbit
Expert Mod 10K+
P: 12,370
It would help to see the updated code.
Jan 29 '12 #14

syedshaffee
P: 91
here is the code that is edited
Expand|Select|Wrap|Line Numbers
  1. dim i
  2. dim checkboxValue
  3. dim TextBoxValue
  4.  
  5. dim Count
  6. dim Count1
  7. dim postion
  8. dim postion1
  9. position=0
  10. postion1=0
  11. i=0
  12. Checkbox1= Request.Form("same")
  13. strdate=Request.Form("Date")
  14. a=Split(strdate ,",")
  15. b=Split(Checkbox1,",")
  16.  
  17. if strdate<>"" and Checkbox1<>"" then
  18. TextBoxValue=UBound(a)
  19. checkboxValue=UBound(b)
  20. 'Response.Write(TextBoxValue)
  21. while not rstAssetdesc.EOF
  22. Des = rstAssetdesc("Asset_type_description")
  23. if TextBoxValue  > checkboxValue then
  24. for i=0 to  checkboxValue
  25.  
  26. objRIMSConn.Execute "Insert into Eot_returned (Contract_no,Eot_action,Asset_id,Asset_description,Date) values ('" + Session("Contract_no") + "','" + Session("EotAction") + "'," + b(i) + ",'" + Desc + "', '" + a(i)+ "');"
  27. next
  28.  
  29.     else
  30.     for i=0 to TextBoxValue
  31.     objRIMSConn.Execute "Insert into Eot_returned (Contract_no,Eot_action,Asset_id,Asset_description,Date) values ('" + Session("Contract_no") + "','" + Session("EotAction") + "'," + b(i) + ",'" + Desc + "', '" + a(i)+ "');"
  32. next
  33. end if
  34. Response.Write("<script language='javascript' type='text/javascript'> alert('The value hass been Inserted'); </script>")
  35.      else
  36.     Response.Write("<script language='javascript' type='text/javascript'> alert('Do you want to return any asset'); </script>")
  37. end if 
  38.  
Jan 30 '12 #15

Rabbit
Expert Mod 10K+
P: 12,370
date is a reserved keyword. If you're going to use it as a field name, you need to demarcate it as such. Different DBMS will have different methods of demarcation. So you'll need to look up the method for your particular DBMS.
Jan 30 '12 #16

syedshaffee
P: 91
ok i checked that and i changed the name of the field but now can u help me with the loop b'coz the values are doubled in the table
Jan 30 '12 #17

Rabbit
Expert Mod 10K+
P: 12,370
I have no idea what values are being passed and what your intentions are. I can't help without knowing those.
Jan 30 '12 #18

jhardman
Expert 2.5K+
P: 3,405
OK, this is a really useful technique I have been doing for over 10 years whenever I don't get the response from the db that I expect:

print out (output to the screen) the SQL statement instead of sending it to the dbms. That way you can look at it and see where it is going wrong. 90% of the time as soon as you look at it you can tell why you are getting a funny response like getting two records added instead of one.

Jared
Feb 10 '12 #19

Post your reply

Sign in to post your reply or Sign up for a free account.