473,507 Members | 2,405 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Errors Creating a datagridview with Checkboxes

3 New Member
I am Getting an error of
Title: DataGridView Default Error Dialog
Content: The following Exception occurred in the DataGridView:
System.Exception: Sent to Pinnacle 01/23/2012 is not a valid Value for Double. ---> System.FormatException: Input String was not in a correct Format.
at System.number.stringtoNumber(String str, NumberStyles Options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
There is more to this error but pretty much the same content as above over and over again.

Expand|Select|Wrap|Line Numbers
  1.     Private Sub LoadExceptions(ByVal ct As Integer, ByVal sqlQry As String)
  2.         grdExceptions.BringToFront()
  3.         grdExceptions.Rows.Clear()
  4.         grdExceptions.Columns.Clear()
  5.  
  6.         Dim strSql As String
  7.  
  8.         Dim ownerFld As String = cbOwner.Text '.Substring(1, 1)
  9.         Dim contractFld As String = cbContract.Text '.Substring(1, 1)
  10.         Dim ResortID As String = lvResortsA.SelectedItems(0).SubItems(0).Text.ToString.Split(":")(0)
  11.  
  12.         Dim recCt As Integer = grdResult.RowCount
  13.         Dim sqldr As SqlDataReader
  14.  
  15.         Dim myFields As String = "Updated:ResortID:OwnerID:ContractID:Collector:Description:User1:User2:User3:User4:User5:Errors "
  16.  
  17.  Dim splitFlds() As String = myFields.Split(":")
  18.         Dim fldct As Integer = myFields.Split(":").Count
  19.         For F As Integer = 0 To fldct - 1
  20.             Dim colName As String = splitFlds(F)
  21.             If F = 0 Then
  22.                 Dim ChkBox As New DataGridViewCheckBoxColumn
  23.                 grdExceptions.Columns.Insert(0, ChkBox)
  24.                 grdExceptions.Columns(F).Name = colName
  25.                 grdExceptions.Columns(F).ReadOnly = False
  26.             Else
  27.                 grdExceptions.Columns.Add(colName, colName)
  28.                 grdExceptions.Columns(F).ReadOnly = False
  29.             End If
  30.         Next
  31.  
  32.         Dim hdrRec As Integer = 0
  33.         If rbYes.Checked Then hdrRec = 1
  34.         ProgressBar1.Maximum = grdResult.RowCount - (hdrRec + 1)
  35.         ProgressBar1.Step = 1
  36.         If hdrRec = 1 Then recCt = recCt - 1
  37.         For D As Integer = (0 + hdrRec) To recCt - 1
  38.  
  39.             ProgressBar1.PerformStep()
  40.             Dim OwnerId As String = grdResult.Rows(D).Cells(ownerFld).Value.ToString.Trim
  41.             Dim ContractId As String = grdResult.Rows(D).Cells(contractFld).Value.ToString.Trim
  42.             'myWhere = " where "
  43.  
  44.             Try
  45.                 Dim Con As New SqlConnection(g_DbConnStrings.CudbSqlConnStr)
  46.                 Con.Open()
  47.                 Dim rdr As SqlDataReader = Nothing
  48.                 strSql = sqlQry
  49.  
  50.                 If strSql.ToString.ToUpper.Contains("WHERE") Then
  51.                     strSql &= " AND ownerID = '" & OwnerId & "' and contractID = '" & ContractId & "' and ResortID = '" & ResortID & "'"
  52.                 Else
  53.                     strSql &= " Where ownerID = '" & OwnerId & "' and contractID = '" & ContractId & "' and ResortID = '" & ResortID & "'"
  54.                 End If
  55.                 Dim Rw As vs.Controls.TableView.Row
  56.                 Dim cmd As New SqlCommand(strSql, Con)
  57.  
  58.                 rdr = cmd.ExecuteReader()
  59.                 While rdr.Read
  60.  
  61.                     ProgressBar1.PerformStep()
  62.                     gLblStatus.Text = "Searching for Exceptions"
  63.                     gLblStatus.gLblPulse = True
  64.  
  65.                     Dim errText As String = ""
  66.                     Dim ckErr As Boolean = False
  67.                     Dim collector As String = IIf(IsDBNull(rdr.Item(3).ToString.Trim), "", rdr.Item(3).ToString.Trim)
  68.                     If ckUD6a.Checked = True Then
  69.                         If collector.Trim <> cbUD6a.Text.Split(":")(0).Trim Then
  70.                             ckErr = True
  71.                             errText = " Invalid Collector;"
  72.                         End If
  73.                     End If
  74.                     Dim note As String = IIf(IsDBNull(rdr.Item(4).ToString.Trim), "", rdr.Item(4).ToString.Trim) 'Sample Output = 'Sent to Pinnacle 01/23/2012'
  75.                     If ckAddDesc.Checked = True Then
  76.                         If txtDescription.Text.Trim <> note Then
  77.                             ckErr = True
  78.                             errText &= " Invalid Description;"
  79.                         End If
  80.                     End If
  81.  
  82.                     Dim UD1 As String = IIf(IsDBNull(rdr.Item(5).ToString.Trim), "", rdr.Item(5).ToString.Trim) 'Sample Output = Collections'
  83.                     If ckUD1a.Checked = True Then
  84.                         If cbUD1a.Text.Trim <> UD1 Then
  85.                             ckErr = True
  86.                             errText &= " Invalid User Field 1;"
  87.                         End If
  88.                     End If
  89.  
  90.                     Dim UD2 As String = IIf(IsDBNull(rdr.Item(6).ToString.Trim), "", rdr.Item(6).ToString.Trim) 'Sample Output = 'Nothing'
  91.                     If ckUD2a.Checked = True Then
  92.                         If cbUD2a.Text.Trim <> UD2 Then
  93.                             ckErr = True
  94.                             errText &= " Invalid User Field 2;"
  95.                         End If
  96.                     End If
  97.                     Dim UD3 As String = IIf(IsDBNull(rdr.Item(7).ToString.Trim), "", rdr.Item(7).ToString.Trim) 'Sample Output = 'Nothing'
  98.                     If ckUD3a.Checked = True Then
  99.                         If cbUD3a.Text.Trim <> UD3 Then
  100.                             ckErr = True
  101.                             errText &= " Invalid User Field 3;"
  102.                         End If
  103.                     End If
  104.                     Dim UD4 As String = IIf(IsDBNull(rdr.Item(8).ToString.Trim), "", rdr.Item(8).ToString.Trim) 'Sample Output = 'Nothing'
  105.                     If ckUD4a.Checked = True Then
  106.                         If cbUD4a.Text.Trim <> UD4 Then
  107.                             ckErr = True
  108.                             errText &= " Invalid User Field 4;"
  109.                         End If
  110.                     End If
  111.                     Dim UD5 As String = IIf(IsDBNull(rdr.Item(9).ToString.Trim), "", rdr.Item(9).ToString.Trim) 'Sample Output = ''
  112.                     If ckUD5a.Checked = True Then
  113.                         If cbUD5a.Text.Trim <> UD5 Then
  114.                             ckErr = True
  115.                             errText &= " Invalid User Field 5;"
  116.                         End If
  117.                     End If
  118.                     If ckErr = True Then
  119.                         grdResult.Rows.Item(D).Cells(0).Value = True
  120.                     Else
  121.                         grdResult.Rows.Item(D).Cells(0).Value = False
  122.                     End If
  123.                     grdResult.Rows(D).Cells(1).Value = ResortID
  124.                     grdResult.Rows(D).Cells(2).Value = OwnerId
  125.                     grdResult.Rows(D).Cells(3).Value = ContractId
  126.                     grdResult.Rows(D).Cells(4).Value = collector
  127.                     grdResult.Rows(D).Cells(5).Value = note  ''System.Exception: Sent to Pinnacle 01/23/2012 is not a valid Value for Double. --->
  128.                     grdResult.Rows(D).Cells(6).Value = UD1  ''System.Exception: Collections is not a valid Value for Decimal. --->
  129.                     grdResult.Rows(D).Cells(7).Value = UD2  ''System.Exception: is not a valid Value for Decimal. --->
  130.                     grdResult.Rows(D).Cells(8).Value = UD3
  131.                     grdResult.Rows(D).Cells(9).Value = UD4
  132.                     grdResult.Rows(D).Cells(10).Value = UD5
  133.                     grdResult.Rows(D).Cells(11).Value = errText
  134.  
  135.  
  136.                 End While
  137.                 rdr.Close()
  138.                 Con.Close()
  139.  
  140.  
  141.  
  142.             Catch ex As System.Exception
  143.                 MsgBox(ex.Message, MsgBoxStyle.Critical)
  144.                 Sys.IO.MyLog.Write(Date.Today, ": " & ex.Message, EventLogEntryType.Error)
  145.             End Try
  146.  
  147.         Next
  148.         gLblStatus.Text = "Waiting on User...."
  149.         gLblStatus.gLblPulse = False
  150.         ProgressBar1.Value = 0
  151.         sqlConnections.Close()
  152.         SqlCmd = Nothing
  153.         sqldr = Nothing
  154.  
  155.  
  156.     End Sub
  157.  
I am basically updating my database with my results table and this routine goes back in and checks the database to ensure all fields were updated correctly with the appropriate data and checks any boxes where the results brought back are incorrect or do not match, or the row was skipped based on criteria specified on my original Query.

I apologize for the immature style of coding as I am self educated in VB.Net Programming. I am sure there are more effective ways to accomplish what I have written, but for the most part my code does exactly what I need it to do.

Thank you for any assistance you can offer!
If you need more information I would be happy to provide anything you may need to assist me.

-Amanda-
Jan 30 '12 #1
0 1536

Sign in to post your reply or Sign up for a free account.

Similar topics

8
2810
by: DylanM | last post by:
I have some checkboxes that are generated from the results of a database search. At the moment, the checkboxes are part of a table making up a form. Users are going through the form, clicking the...
7
2446
by: Boogie El Aceitoso | last post by:
Hi, I have a class whose constructor accepts a filename and performs some actions on it. Some things might go wrong, such as not being the right kind of file, the file doesn't exist, is...
9
3520
by: hazz | last post by:
I want to display 'n' records for a table-driven data entry page. The first column should be readonly and the 2nd column, a checkbox WRITABLE (NOT READONLY). I can't use the gridview because it...
2
8707
by: Rick Shaw | last post by:
Hi, I have a problem with the datagridview not refreshed when the application first appear on the screen. The datagridview display data from a table in the dataset. At the same time, I've added...
4
21271
by: Hexman | last post by:
Hello All, I'd like to find out the best way to add a cb column to a dgv and process efficiently. I see at least two ways of doing it. ------------------------------- 1) Add a cb to the dgv,...
2
4273
by: mrstrong | last post by:
Gday, I have a datagridview that I am creating the columns programatically which all seems to work fine. I have a couple of dropdown boxes, so I have set the editMode= EditOnEnter. Now my...
2
6103
by: mrstrong | last post by:
Gday, Why would all my checkboxes inside a datagridview stop working (ie checked state not updating when user clicks) when the datagridview's editmode property is changed to "EditOnEnter"? It...
3
5476
by: Burton Roberts | last post by:
I am "Walking Through" the VB Team's walkthrough of WCF support in VS2008. In the IService interface the <ServiceContract()indicates an error "Type 'ServiceContract' is not defined" and both...
8
9024
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
If I populate a DataGridView with a query supplied at runtime, boolean fields render as a CheckBox instead of just a text rendering of '0' or '1'. That is nice sometimes, but I would like the...
1
3761
by: =?Utf-8?B?VGFtbXk=?= | last post by:
Hi! I am using VB 2008 with SQL Server 2000 and SQL Server 2005 (depending which server the user selects to connect to). I have a combox in which the user types the server to connect to. ...
0
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7321
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7034
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5623
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5045
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1544
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.