[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:
Dim conn As MySqlConnection
'connect to DB
conn = New MySqlConnection()
conn.ConnectionString = "server=localhost; user id=root; password=chart; database=login"
'see if connection failed.
Try
conn.Open()
Catch myerror As MySqlException
MessageBox.Show("Error Connecting to Database: " & myerror.Message)
End Try
Dim myAdapter As New MySqlDataAdapter
Dim sqlquery As String
sqlquery = "INSERT INTO user (LastName, FirstName, e-mail, Username, Password, Deleted, Administrator, Created) VALUES(?lname, ?firstn, ?email, ?usernam, ?pword, ?Dels, ?admin, ?times)"
Dim myCommand As New MySqlCommand()
myCommand.Connection = conn
myCommand.CommandText = sqlquery
myCommand.Parameters.AddWithValue("?usernam", TextBox1.Text)
myCommand.Parameters.AddWithValue("?pword", MaskedTextBox1.Text)
myCommand.Parameters.AddWithValue("?lname", TextBox4.Text)
myCommand.Parameters.AddWithValue("?firstn", TextBox2.Text)
myCommand.Parameters.AddWithValue("?email", TextBox3.Text)
myCommand.Parameters.AddWithValue("?dels", "False")
myCommand.Parameters.AddWithValue("?admin", "False")
myCommand.Parameters.AddWithValue("?times", DateString & " " & TimeString)
'start query
myCommand.ExecuteScalar()
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
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
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
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
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
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
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
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.