PC Review


Reply
Thread Tools Rate Thread

DataSet Update Command Error

 
 
Duppypog
Guest
Posts: n/a
 
      21st Jul 2003
I have a dataset that I want to use an update command to update the
underlying table. I have fields that are not mandatory. I'm getting an
error when there is no data in any one of the textboxes. What do I need to
do differently to accomodate empty textboxes?

Here's a code snippet:
Dim iRIN As Integer = CType(e.Item.FindControl("txtRIN"), TextBox).Text
Dim sDiv As String = CType(e.Item.FindControl("txtDivision"), TextBox).Text
Dim sCall As String = CType(e.Item.FindControl("txtCall"), TextBox).Text
Dim sDistrict As String = CType(e.Item.FindControl("txtDistrict"),
TextBox).Text
Dim sAssignment As String = CType(e.Item.FindControl("txtAssignment"),
TextBox).Text
Dim sSerial As String = CType(e.Item.FindControl("txtSerial"), TextBox).Text
Dim sTG As String = CType(e.Item.FindControl("txtTalkgrp"), TextBox).Text
Dim sModel As String = CType(e.Item.FindControl("txtModel"), TextBox).Text
Dim bMike As Boolean = CType(e.Item.FindControl("txtMike"), TextBox).Text
Dim bCharger As Boolean = CType(e.Item.FindControl("txtCharger"),
TextBox).Text
Dim iChargerNo As String = CType(e.Item.FindControl("txtChargerNo"),
TextBox).Text
Dim sOwner As String = CType(e.Item.FindControl("txtOwner"), TextBox).Text
Dim dRepair As String = CType(e.Item.FindControl("txtRepair"), TextBox).Text
Dim iScanNo As Integer = CType(e.Item.FindControl("txtScanNo"),
TextBox).Text
Dim sRemarks As String = CType(e.Item.FindControl("txtRemarks"),
TextBox).Text
Dim sCount As String = CType(e.Item.FindControl("txtCount"), TextBox).Text
Dim key As Integer = DataList1.DataKeys(e.Item.ItemIndex)

Dim strSQL As String = "UPDATE Radios SET Count = '" & sCount & "',
strSerialNumber = '" & sSerial & "' , strCall = '" & sCall & "'"
strSQL = strSQL & ", intRIN6Digit = " & iRIN & ", strModel = '" & sModel &
"', strAssignment = '" & sAssignment & "'"
strSQL = strSQL & ", strDistrict-Section = '" & sDistrict & "', strTalkGroup
= '" & sTG & "', intAssetTagNo = " & iScanNo & ""
strSQL = strSQL & ", dtSentForRepair = #" & dRepair & "#, strRemarks = '" &
sRemarks & "', strDivision = '" & sDiv & "'"
strSQL = strSQL & ", bIndividualCharger = " & bCharger & ", bP-S_Mike = " &
bMike & ", strOwner = '" & sOwner & "', intChargerNumber = " & iChargerNo &
"WHERE intRIN6Digit = " & key & ""

Try
Dim cmd As New OleDbCommand(strSQL, cnn)
cnn.Open()
Dim objDataReader As OleDbDataReader
objDataReader = cmd.ExecuteReader()
DataList1.DataSource = objDataReader
FillDataList()



Thanks much!!
Lynnette


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
error with dataset update =?Utf-8?B?QlZBMzEwNQ==?= Microsoft VB .NET 0 10th Nov 2006 09:34 AM
How to know which command executed for DataAdapter.Update(DataSet) Samy Microsoft ASP .NET 0 16th Nov 2005 04:51 AM
Using the datagrid update command to alter data in a dataset Paul Custance Microsoft Dot NET Framework 0 15th Mar 2005 11:13 PM
dataset update error Marina Microsoft ADO .NET 4 9th Sep 2003 07:28 AM
dataset update error drishtik Microsoft Dot NET Framework 0 8th Sep 2003 08:22 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:12 PM.