Results 1 to 8 of 8

Thread: Need Help

  1. #1
    Join Date
    Jul 2011
    Posts
    13

    Unanswered: 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)

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    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
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jul 2011
    Posts
    13
    No, i am using C#.net

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    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
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    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)"

  6. #6
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    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?

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

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

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •