If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Need Help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-11-11, 14:52
chavala chavala is offline
Registered User
 
Join Date: Jul 2011
Posts: 13
Need Help

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.21.37.38:0, 2011_06_22_00_00, 2, 2, InProgress)' at line 1
================================================== ==================
string query = "INSERT INTO usagetable (FeatureName, loginID, uniqueID, logintime, sflag, duration, status) VALUES("+fname+", "+lID+", "+uID+", "+ltime+", "+lag+", "+dur+", "+st+")";
values inside the variables are as follows...
fname= mgncdjkj
lID = mgkrc
uID = mgrdjjncj.jkdcsc.172.21.37.38:0
ltime = 2011_06_22_00_00
lag = 2
dur = 2
st = InProgress
================================================== ========
data-types in MYSQL
FeatureName (Varchar(30)),
loginID (Varchar(30)),
uniqueID (Varchar(30)),
logintime (Varchar(30)),
sflag integer,
duration integer,
status Varchar(30)
Reply With Quote
  #2 (permalink)  
Old 07-11-11, 15:02
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
Quote:
Originally Posted by chavala View Post
string query = "INSERT ...
this is php?

please do an echo of the query string just before it is executed and you get that error message
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 07-11-11, 15:13
chavala chavala is offline
Registered User
 
Join Date: Jul 2011
Posts: 13
No, i am using C#.net
Reply With Quote
  #4 (permalink)  
Old 07-11-11, 15:30
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
Quote:
Originally Posted by chavala View Post
No, i am using C#.net
okay, that's fine

the concept "echo" should mean something, though

i'd like to see the actual query text that was passed to mysql, not your C code which builds the query string by concatenating variables into it
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 07-11-11, 15:40
chavala chavala is offline
Registered User
 
Join Date: Jul 2011
Posts: 13
query = "INSERT INTO usagetable (FeatureName, loginID, uniqueID, logintime, sflag, duration, status) VALUES(\"boaryout_c\", leledit, leleaditroyal.patni.com172.21.37.38:0, 2011_06_22_00_00, 2, 2, InProgress)"
Reply With Quote
  #6 (permalink)  
Old 07-11-11, 16:09
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
you've forgotten to put quotes around your strings and dates, and your date values are incorrect

leledit is a column name, whereas 'leledit' is a string value suitable for the loginID column

2011_06_22_00_00 is an identifier, whereas '2011-06-22 00:00' is a datetime value suitable for the logintime column

see the difference?

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #7 (permalink)  
Old 07-11-11, 17:15
chavala chavala is offline
Registered User
 
Join Date: Jul 2011
Posts: 13
I have considered the date as varchar...instead of parsing the string to date format....
If i consider the ' ' then value in the variable is not retrieving....
Example:
Since, I am getting the values from a variables. I can pass only variable names in the INSERT query. I am not be able to pass the direct strings.

variable name : lID
if i specify that as
'+lID+' --then it is representing text as a unicode. And lID is inserting into my table not the value in the variable.

but when i specify
"+lID+" -- it gives value in the variable.
Reply With Quote
  #8 (permalink)  
Old 07-12-11, 09:52
chavala chavala is offline
Registered User
 
Join Date: Jul 2011
Posts: 13
Thank you r937,
I got it....i have modified the query by placing the variables inside the single quotes...
' "-----" '
Thank you for your help
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On