Hello can someone tell me why i got this problem.
I'm trying to create 1 main form and inside i have panel that will load other form inside it. And i have the problem when my query is runned inside the database its filled with empty fields, looks like it doesnt read what has inside the textboxes and checkboxes are they checked if they are is "1"
Here is my main form calling inside the panel the other form :
Dim form2 As UsersAddCP = New UsersAddCP()
form2.TopLevel = False
form2.TopMost = True
Dim form1 As AdminMenu = CType(Application.OpenForms("AdminMenu"), AdminMenu)
Dim panel1 As Panel = CType(form1.Controls("panel1"), Panel)
panel1.Controls.Clear()
panel1.Controls.Add(form2)
form2.Show()
And here is my query module to insert the information.
Public Sub RegisterUser()
Try
With cmd
.Connection = conn
.CommandText = "INSERT INTO users (uname,upassword,ucode,ucreate,utools,usearch) VALUES (@user,@pass,@ucd,@crt,@uto,@usrh)"
.Parameters.AddWithValue("@user", UsersAddCP.txtUsername.Text)
.Parameters.AddWithValue("@pass", UsersAddCP.txtPassword.Text)
.Parameters.AddWithValue("@ucd", UsersAddCP.AdminCheck.Checked)
.Parameters.AddWithValue("@crt", UsersAddCP.CreateCheck.Checked)
.Parameters.AddWithValue("@uto", UsersAddCP.ToolsCheck.Checked)
.Parameters.AddWithValue("@usrh", UsersAddCP.SearchCheck.Checked)
.ExecuteNonQuery()
.Parameters.Clear()
.CommandText = "INSERT INTO personal (pacc,pName,pEmail,pYazaki,pPhone,pPosition) VALUES (@user,@name,@email,@yazaki,@phone,@position)"
.Parameters.AddWithValue("@user", UsersAddCP.txtUsername.Text)
.Parameters.AddWithValue("@name", UsersAddCP.txtName.Text)
.Parameters.AddWithValue("@email", UsersAddCP.txtEmail.Text)
.Parameters.AddWithValue("@yazaki", UsersAddCP.txtyazaki.Text)
.Parameters.AddWithValue("@phone", UsersAddCP.txtPhone.Text)
.Parameters.AddWithValue("@position", UsersAddCP.txtPossition.Text)
Result = .ExecuteNonQuery
End With
Catch ex As Exception
MsgBox(ex.Message)
Finally
If Result > 0 Then
MessageBox.Show("Sign Up Successful", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
MsgBox("Failed to register user!")
End If
cmd.Dispose()
If conn IsNot Nothing Then
conn.Close()
End If
End Try
End Sub
End Module
Problem is only when i use to load the form inside the panel.
If i use normal Form Loads and fill out the fields records are readed and inserted in database fields, but when i use the panel in database create empty fields..Strange maybe someone can help me out how to solve it?
What I have tried:
Normal loading form and insert records - works
Load in panel other form and insert records - give empty fields in database