Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: Update Issue


Message #1 by steveproctor@c... on Thu, 4 Jul 2002 18:15:09
I have had problems with update using ASP.NET, but am slowly learning.  
But the most recent problem has me stumped.

1)  At first, the update did not record the new data in the text box, but 
showed the old data.

2)  Then I deleted the contents in the text box, pressed update.  I got an 
error message that I could not use a zero length string.  I pressed the 
back  button, entered the new data I wanted and it showed the new data!

3)  I next tried entering the new data and pressing enter on the 
keyboard.  Then I pressed update, and the old data was retained.  But then 
I pressed edit, the new data showed in the text box!  Then I press update 
again and it showed the new data!

Something is wrong with how the program is capturing the information in 
the text box.  Should I add a TextChanged event to the update subroutine?  
Any other ideas?

The code for update is below:

Public Sub DataGrid_Update(Source As Object, E As DataGridCommandEventArgs)
		Dim Conn As OleDbConnection
		Dim objCmd as OleDbCommand
		Dim txtEntityName As TextBox = E.Item.Cells(2).Controls(0)
		Dim strUpdate As String
		
		strUpdate = "UPDATE MainTable SET " & _
			"EntityName = '" & txtEntityName.Text & "' WHERE 
Number = " & E.Item.Cells(1).Text
		
		'CONNECTION IS INSERTED HERE
		objCmd = New OleDbCommand(strUpdate, Conn)
		Conn.Open()
		objCmd.ExecuteNonQuery()
		CorpInfo.EditItemIndex = -1
                BindData()
		Conn.Close()
	End Sub

Thanks

Steve

  Return to Index