hey
im in the middle of doing sql queries i can search my data base using
GetDateFrom (Select, from, where)

Me.nameTableAdapter.FillBy(namenDataSet.descip, Me.box1TextBox.Text, Me.box1TextBox.Text, Me.box2TextBox.Text, Me.box2TextBox.Text)

i have this working fine im struggling with inderting data to my databse i have made the query ..

INSERT INTO `details` (`Forename`, `Surname`, `Username`, `Password`)
 VALUES (''& ForenameTextBox.Text &'', ''& SunameTextBox.Text &'', ''& UsernameTextBox &'', ''& PasswordTextBox &'')

im not sure if this is right as when i call it it doesnt work i have this code for that..

Private Sub Save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.nameTableAdapter.InsertQuery(nameDataSet.descrip, UsernameTextBox.Text, PasswordTextBox.Text, ForenameTextBox.Text, SurnameTextBox.Text)
    End Sub

im faced with an error saying my namedataset and descripdatatabe cannot be converted into a string

would like to know where im going wrong

Dani AI

Generated

— the error about a DataTable not being convertible to String comes from passing your dataset/table object into an Insert method. Fill-style methods expect a DataTable to fill; generated Insert/InsertQuery methods expect the column values (or a typed DataRow), not the DataTable itself. is correct that string literals need quotes in raw SQL, but in this case the runtime type mismatch is the root cause.

Two correct approaches:

  • Call the TableAdapter insert method with the column values only (check the exact parameter order in IntelliSense or the Dataset Designer). Do not pass the DataSet/DataTable as an argument to the insert call.

  • Use a typed DataRow, add it to the DataTable, then call Update on the TableAdapter. Example pattern:

Dim r As MyDataSet.MyTableRow = myDataSet.MyTable.NewMyTableRow()
r.Forename = ForenameTextBox.Text
r.Surname  = SurnameTextBox.Text
r.Username = UsernameTextBox.Text
r.Password = PasswordTextBox.Text
myDataSet.MyTable.AddMyTableRow(r)
myTableAdapter.Update(myDataSet.MyTable)

Troubleshooting and safety tips:

  • Inspect the generated Insert/InsertQuery signature in the Dataset Designer or via IntelliSense to confirm the parameter list and order.
  • Prefer parameterized commands over string concatenation to avoid quoting headaches and SQL injection.
  • Never store plaintext passwords — hash with a strong algorithm (PBKDF2, bcrypt, Argon2) before saving.
  • Use Try/Catch around database calls and set breakpoints to verify the actual values and call order being passed to the adapter.

Recommended Answers

All 2 Replies

Non-numeric field value must enclosed with ' (single quote).

INSERT INTO `details` (`Forename`, `Surname`, `Username`, `Password`)
 VALUES ('" & ForenameTextBox.Text & "', '" & SunameTextBox.Text & "', '" & UsernameTextBox & '", '" & PasswordTextBox & "')"

hey thanks for the help but i still think im doing something wrong as when i call the query im still getting the same error message that my data table cannot be converted into a string.
do i call the wuery just like i called the query in the select query?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.