Results 1 to 9 of 9

Thread: [RESOLVED] sytax error and checking user privlages for chat app and createing a buddy list

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2009
    Location
    Scotland/Japan
    Posts
    164

    Resolved [RESOLVED] sytax error and checking user privlages for chat app and createing a buddy list

    hello i have a chat app im developing and have now got it to login and that but now have a new issue when a user logs in i want it to check what level of privlages the user has then enable the corisponding controls and also set the users tag eg admin(server admin) and so on



    also i want to add a buddy list that shows if a user is online or offline but i have no idea how to display the username's the user adds to there freinds or how to display there status on the buddy list form

    also when the user registers im getting a MYSQL syntax error on this line of code

    vb Code:
    1. Dim conn As MySqlConnection
    2.  
    3.         'connect to DB
    4.         conn = New MySqlConnection()
    5.         conn.ConnectionString = "server=localhost; user id=root; password=chart; database=login"
    6.         'see if connection failed.
    7.         Try
    8.             conn.Open()
    9.         Catch myerror As MySqlException
    10.             MessageBox.Show("Error Connecting to Database: " & myerror.Message)
    11.         End Try
    12.         Dim myAdapter As New MySqlDataAdapter
    13.  
    14.         Dim sqlquery As String
    15.         sqlquery = "INSERT INTO user (LastName, FirstName, e-mail, Username, Password, Deleted, Administrator, Created) VALUES(?lname, ?firstn, ?email, ?usernam, ?pword, ?Dels, ?admin, ?times)"
    16.         Dim myCommand As New MySqlCommand()
    17.         myCommand.Connection = conn
    18.         myCommand.CommandText = sqlquery
    19.         myCommand.Parameters.AddWithValue("?usernam", TextBox1.Text)
    20.         myCommand.Parameters.AddWithValue("?pword", MaskedTextBox1.Text)
    21.         myCommand.Parameters.AddWithValue("?lname", TextBox4.Text)
    22.         myCommand.Parameters.AddWithValue("?firstn", TextBox2.Text)
    23.         myCommand.Parameters.AddWithValue("?email", TextBox3.Text)
    24.         myCommand.Parameters.AddWithValue("?dels", "False")
    25.         myCommand.Parameters.AddWithValue("?admin", "False")
    26.         myCommand.Parameters.AddWithValue("?times", DateString & " " & TimeString)
    27.  
    28.         'start query
    29.         myCommand.ExecuteScalar()
    Last edited by casirus; Sep 18th, 2009 at 11:01 AM.
    Between the world we see and the things we fear theres a realm of possibility

    D.L.H. Ind.

    We do what we do in out life to make Yours Simpler

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: sytax error and checking user privlages for chat app and createing a buddy list

    check this post....
    http://www.vbforums.com/showthread.php?t=449775

    See if it helps...

    I think you're getting conflicts with your fieldnames and resrved keywords.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2009
    Location
    Scotland/Japan
    Posts
    164

    Re: sytax error and checking user privlages for chat app and createing a buddy list

    well i looked and dont see that issue

    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 '-mail, Username, Password, Deleted, Administrator, Created) VALUES('test', '' at line 1
    Between the world we see and the things we fear theres a realm of possibility

    D.L.H. Ind.

    We do what we do in out life to make Yours Simpler

  4. #4
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: sytax error and checking user privlages for chat app and createing a buddy list

    Administator,Password are normally reserved words in any database system and you should not have any fields named that way
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jul 2009
    Location
    Scotland/Japan
    Posts
    164

    Re: sytax error and checking user privlages for chat app and createing a buddy list

    so would i rename the 2 table entrys and then it should work
    Between the world we see and the things we fear theres a realm of possibility

    D.L.H. Ind.

    We do what we do in out life to make Yours Simpler

  6. #6
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: sytax error and checking user privlages for chat app and createing a buddy list

    it could also be "e-mail" ... which is getting interpreted as e minus mail .... invalid syntax in any SQL.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jul 2009
    Location
    Scotland/Japan
    Posts
    164

    Re: sytax error and checking user privlages for chat app and createing a buddy list

    Thanks it stoped giveing me the error but now it says user_ID does not have a defalt value when it is an auto increment Intger
    Between the world we see and the things we fear theres a realm of possibility

    D.L.H. Ind.

    We do what we do in out life to make Yours Simpler

  8. #8
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: sytax error and checking user privlages for chat app and createing a buddy list

    Not sure about that... are you *sure* about the auto inc integer?

    one other thing I did notice... you're not returning anything, so there's no reason to use .ExecuteScalar .... use .ExecuteNonQuery instead.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  9. #9
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: sytax error and checking user privlages for chat app and createing a buddy list

    Is User_Id the Priamry Key for the table? IF so what I think it is telling you is that you are not supplying a value for it and it needs to be supplie, or a default needs to be set up on the database (but if this is a PK the do not use a default). Or you need to set the data type (I do not know MySQL) to something that auto increments itself when the row is added.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

Posting Permissions

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



Click Here to Expand Forum to Full Width