Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: ASP.NET Databases Using VB.NET - Page 240


Message #1 by steveproctor@c... on Sun, 15 Sep 2002 14:10:06
I'm trying to work through the update example on page 240 of the above 
book.  I'm using a database I created myself applying the code in the 
example.  But it won't work.  The problem is that the UpdateRMChecks 
subroutine won't capture the variables in the preceding Update Record 
subroutine.  I'm confused how this was done in the example in the book.  
The error message I am getting is that the Initials field cannot be a zero 
length string.

Below is the portion of the code which is the problem.

Public Sub UpdateRecord(ByVal Sender As Object, ByVal E  As 
DataGridCommandEventArgs)
	
	Dim intRequestNumber As Int32 = Convert.ToInt32(E.Item.Cells
(0).Text)
	
	Dim strInitials As String = E.Item.Cells(1).Text
	
	Dim datRequestDate As DateTime = #08/25/2002#
	
	Dim decAmount As Decimal = "68.00"
	
	
	Dim strPayee As String = E.Item.Cells(4).Text
	Dim strForm As String = E.Item.Cells(5).Text
	Dim strClient As String = E.Item.Cells(6).Text
	Dim strAlien As String = E.Item.Cells(7).Text
	Dim strFile As String = E.Item.Cells(8).Text
	
	
	UpdateRMChecks(intRequestNumber, strInitials, datRequestDate, 
decAmount, strPayee, strForm, strClient, strAlien, strFile)
End Sub
	
Private Sub UpdateRMChecks(ByVal intRequestNumber As Long, ByVal 
strInitials As String, _
	ByVal RequestDate As Date, ByVal Amount As Decimal, ByVal Payee As 
String, _
	ByVal Form As String, ByVal Client As String, _
	ByVal Alien As String, ByVal File As String)

	Connect()
	Dim adapter As New OleDbDataAdapter(strSQLSelect, objConnection)
	Dim ds As New DataSet()
	adapter.Fill(ds, RequestTableName)
	Disconnect()
	
	Dim tbl As DataTable = ds.Tables(RequestTableName)
	tbl.PrimaryKey = New DataColumn() _
		{ _
			tbl.Columns("RequestNumber") _
		}
	Dim row As DataRow = tbl.Rows.Find(intRequestNumber)
	row.Item("Initials") = Initials
	row.Item("RequestDate") = RequestDate
	row.Item("Payee") = Payee
	row.Item("Form") = Form
	row.Item("Client") = Client
	row.Item("Alien") = Alien
	row.Item("File") = File
	
	Dim cb As New OleDbCommandBuilder(adapter)
	Connect()
	adapter.Update(ds, RequestTableName)
	Disconnect()
	
	
	dgRMChecks.DataSource = ds.Tables(RequestTableName)
	dgRMChecks.DataBind()
End Sub

Any help is apppreciated.

Steve

  Return to Index