Imports System.Data.SqlClient
Imports MySql.Data.MySqlClient
Public Class Create_Profile
Dim MySqlConnection As MySqlConnection
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
MySqlConnection = New MySqlConnection("server details have been removed")
MySqlConnection.Open()
'this part I am trying to select a specific user that I want to update
Dim sqlquery As String = "SELECT * FROM Users WHERE Username = '" + Login.UsernameTextBox.Text + "';"
Dim data As MySqlDataReader
Dim adapter As New MySqlDataAdapter
Dim command As New MySqlCommand
command.CommandText = sqlquery
command.Connection = MySqlConnection
adapter.SelectCommand = command
data = command.ExecuteReader
data.Close()
If sqlquery = True Then
'Ths part I am trying to insert data into the specific user in sql
Dim sqlquery2 As String = "INSERT INTO Users (sName, fName)VALUES ('" + TextBox1.Text + "','" + TextBox2.Text + "')"
Dim data2 As MySqlDataReader
Dim adapter2 As New MySqlDataAdapter
Dim command2 As New MySqlCommand
command2.CommandText = sqlquery2
command2.Connection = MySqlConnection
adapter2.SelectCommand = command2
data2 = command2.ExecuteReader
MsgBox("Profile Updated")
Home.Show()
End If
End Sub
End Class
So overall I am try to allow a user to be able to update their user info in sql and later the data will be retrieved and displayed in a different form.
At the moment when I try to run this (obviously with server details) it adds data but as a new user that has no other details.
8 - id
NULL - Username
NULL -Password
m - fName
m- sName
9 - id
NULL - Username
NULL -Password
m - fName
m- sName
There may be a simple solution to this but i dont know lol.
Thanks
Marc

New Topic/Question
Reply



MultiQuote


|