Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Trouble using SQL insert with declared variables

 
Logged in as: Guest
arrSession:exec spGetSession 2,3,285
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> ASP >> Trouble using SQL insert with declared variables
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Trouble using SQL insert with declared variables - 7/20/2001 11:57:23 PM   
  anton

 

Posts: 11
Score: 0
Joined: 6/9/2001
From: USA
Status: offline
I'm writing an ASP page using VBScript to insert data into a SQL
table. After I execute the string I'm getting the error Incorrect
syntax near ')'. The code where I declare the query string is as
follows:

'------------------------------------------------------------------------
InsSicLog = "Insert leads (siclogin) values ("&SicCounter&")"
'------------------------------------------------------------------------

where siclogin is the column name in leads table and SicCounter is
a variable defined earlier in the code.


I know this is just a syntax problem, but I can't figure out what I am
doing wrong. Any help would be greatly appreciated. Thanks!
 
 
Post #: 1
 
 Re: Trouble using SQL insert with declared variables - 7/21/2001 12:01:31 AM   
  winkumpel

 

Posts: 11
Score: 0
Joined: 5/23/2001
From: Netherlands
Status: offline
seems to me you'd need to tell it which table to insert into.

Insert leads(siclogin) into mytable.....

(in reply to anton)
 
 
Post #: 2
 
 Re: Trouble using SQL insert with declared variables - 7/21/2001 12:11:56 AM   
  anton

 

Posts: 11
Score: 0
Joined: 6/9/2001
From: USA
Status: offline
Leads is the name of the table, and siclogin is the name of the
column. The basic format is:

INSERT <tablename> (<columnname>) VALUES (<value>)

If I don't use variables (i.e. &SicCounter&) it works fine. I think I am
just formating the variable in the query string wrong.

(in reply to anton)
 
 
Post #: 3
 
 Re: Trouble using SQL insert with declared variables - 7/21/2001 12:15:11 AM   
  winkumpel

 

Posts: 11
Score: 0
Joined: 5/23/2001
From: Netherlands
Status: offline
Does this work?

"Insert leads (siclogin) values ('" & SicCounter & "')"

(in reply to anton)
 
 
Post #: 4
 
 Re: Trouble using SQL insert with declared variables - 7/21/2001 12:19:11 AM   
  anton

 

Posts: 11
Score: 0
Joined: 6/9/2001
From: USA
Status: offline
That did it! Wierd though, I thought the apostrophe was only to be
used for String identifiers. My field SicLogin was defined as integer in
the SQL DB. I guess VBScript would rather go out and find for itself
what the data type is.

Thanks for your help

(in reply to anton)
 
 
Post #: 5
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> ASP >> Trouble using SQL insert with declared variables Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts