0

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
2
Contributors
1
Reply
3
Views
7 Years
Discussion Span
Last Post by finito
0

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

Edited by finito: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.