| |
|
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.
|
 |

07-11-11, 14:52
|
|
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)
|
|

07-11-11, 15:02
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
|
|
Quote:
Originally Posted by chavala
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
|
|

07-11-11, 15:13
|
|
Registered User
|
|
Join Date: Jul 2011
Posts: 13
|
|
|
|

07-11-11, 15:30
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
|
|
Quote:
Originally Posted by chavala
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
|
|

07-11-11, 15:40
|
|
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)"
|
|

07-11-11, 16:09
|
|
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?

|
|

07-11-11, 17:15
|
|
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.
|
|

07-12-11, 09:52
|
|
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
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|