hello all,
how can I add a user to a table in a mysql database without datagridview ?
I already have this:
Dim conn As MySqlConnection
'connect to DB
conn = New MySqlConnection()
conn.ConnectionString = "server=localhost; user id=root; password=test; database=test_addtable"
'see if connection failed.
Try
conn.Open()
Catch myerror As MySqlException
MsgBox("Error connecting to database!")
End Try
'sql query
Dim myAdapter As New MySqlDataAdapter
Dim sqlquery = "SELECT * FROM user WHERE username = '" + registerform.usernametextbox.Text + "'"
Dim myCommand As New MySqlCommand()
myCommand.Connection = conn
myCommand.CommandText = sqlquery
'start query
myAdapter.SelectCommand = myCommand
Dim myData As MySqlDataReader
myData = myCommand.ExecuteReader()
'see if user exists
If myData.HasRows = 0 Then
conn.Close()
conn.Open()
Dim registerfinal As New MySqlDataAdapter
sqlquery = "INSERT INTO user (Username, Password, Email) VALUES ('" + registerform.usernametextbox.Text + "','" + registerform.passwordtextbox.Text + "','" + registerform.emailtextbox.Text + "')"
myCommand.Connection = conn
myCommand.CommandText = sqlquery
'start query
registerfinal.SelectCommand = myCommand
myData = myCommand.ExecuteReader()
MsgBox("New user has been added to the database!")
'add close
Else
'already exists
End If
where to add the create table??
I need a table which contains the folllowing data:
CREATE TABLE `test_addtable`.`username**` ( **must be username
`id` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`Name` VARCHAR( 45 ) NOT NULL ,
`Downloadlink` VARCHAR( 45 ) NOT NULL ,
`Description` TEXT NOT NULL
) ENGINE = INNODB;
[/LIST]
how to solve this ??
Thanks in common!
Cheers!