I am pretty new to asp.net and I am trying to make a simple form with a few textboxes and dropdown lists. I am using Visual Web Developer 2008 express.
The customer enters their information in the web form and hits the submit button.
When the submit button is hit, I am trying to update one table which will run a query and display the results of another table.
So far, I have the form set up and the drop down lists populated from tables in the db.
I can display the information from any of the fields. I can insert into the table, but what I need to do is first delete all contents of the table and then insert information into the same table. Alternately updating may work, but I am not sure how update works.
I have an old asp page existing that works but it is way past time to update that page.
If I set up gridview, I can select, delete and insert, but I can't figure out how to do this with a submit button.
Any help here would be greatly appreciated - I have been working at this for days.
Here is the code:

Sub OnBtnSendClicked(ByVal s As Object, ByVal e As EventArgs)
		        Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("IndividualRates.mdb") & ";"
	
		        Dim MySQL As String = "UPDATE problemdefinition SET client = @txtname, memberage = @txtage"
		        
		        Dim MyConn As New OleDBConnection(strConn)
		        Dim cmd As New OleDBCommand(MySQL, MyConn)
		        MyConn.Open()
		        cmd.ExecuteNonQuery()
		        MyConn.Close()
	
		        Response.Redirect("gbresults.aspx")
		    End Sub

Try

Dim MySQL As String = "UPDATE problemdefinition SET client = " & txtname.Text & ", memberage = " & txtage.Text

Ofcourse you replace that with your actual data.

If client takes a string which it looks like it does you need ' ' like so

Dim MySQL As String = "UPDATE problemdefinition SET client = '" & txtname.Text & "', memberage = " & txtage.Text

Hmm since I don't have my compiler right available atm.

You may get an error since i think ' is to comment in VB you may need to add an @ at the beginning Try the one above first though

Dim MySQL As String = @"UPDATE problemdefinition SET client = '" & txtname.Text & @"', memberage = " & txtage.Text
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.