Reputation: 35
Protected Sub btnAddSubmit_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnAddSubmit.Click Dim add As String
add = "INSERT INTO account(firstname, lastname, uname, pass, type)" & " VALUES ('" & fname.Text & "','" & lname & "','" & username & "','" & password & "','" & type & "')"
An error pops up at this part "INSERT INTO account(firstname, lastname, uname, pass, type)" & " VALUES ('" & fname.Text & "
The Error: Operator '&' is not defined for types 'String' and 'System.Web.UI.HtmlControls.HtmlInputText'.
The program that I have to create should have the ability to add an account can someone help me? :(
EDIT: I have manage to get it worked but however instead of recording the input in the textbox it shows System.Web.UI.HtmlControls.HtmlInputText in the database (instead of for example Firstname: Tom it shows Firstname: System.Web.UI.HtmlControls.HtmlInputText)
Dim SQLStatement As String = "INSERT INTO account(firstname, lastname, uname, pass, type)" & " VALUES ('" & fname.ToString() & "','" & lname.ToString() & "','" & username.ToString() & "','" & password.ToString() & "','" & type.ToString() & "')"
SaveNames(SQLStatement)
This is what I had change
Upvotes: 0
Views: 5221
Reputation: 216313
As Mr Slacks says you have many problems in your single line of code above.
The lesser one is the use of Text property for an HtmlInputText control.
You should use the property Value for every HtmlInputText (fname, etc...) that you want to get its content.
For the other problems. Start reading about Sql Injection and Parameterized queries and ASP.NET Identity
EDIT Your last edit applies the ToString() method to the instance of the HtmlInputText control and results (as expected) in the fully qualified class name.
You should apply the ToString() method to the Value property
fname.Value.ToString ...... etc....
Upvotes: 0