473,666 Members | 2,114 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.Exceptio n: Sent to Pinnacle 01/23/2012 is not a valid Value for Double. ---> System.FormatEx ception: Input String was not in a correct Format.
at System.number.s tringtoNumber(S tring str, NumberStyles Options, NumberBuffer& number, NumberFormatInf o 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 1546

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

Similar topics

8
2826
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 boxes and saving to the database at the end with the 'Submit' command button. Is it possible to save the changes as the checkboxes are clicked? I suppose I'd need to write some dynamic ASP event handling at the same time as creating the checkboxes......
7
2454
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 read-only, etc... I guess the only way to report an error inside a constructor is to raise an exception, but it feels a bit extreme to raise an exception becuase a file
9
3526
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 creates -> checked="checked" disabled="disabled" What I need is more like this; <form id="form1" runat="server"> <div> <table>
2
8713
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 checkbox columns that are not bounded the table. This datagridview is located in the tab (2nd). I thought I mention that since that might be part of the problem (?). When the applications start, it will need some parameter criteria selection...
4
21292
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, iterate thru the dgv and update the bound fields if the cb has been checked. Then do the update and accept changes. How do I access the cb and its checked status? How to iterate thru dgv? Dim cbSelCol As New DataGridViewCheckBoxColumn
2
4281
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 checkboxes dont seem to work, and the datagridview throws a dataerror when I try to leave the cell after trying to check/uncheck the checkbox?!
2
6117
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 seems to return an error: "Formatted Value of the cell has wrong type". It works fine when the datagridview's editmode property is
3
5511
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 <OperationContract()are indicate "Type 'OperationContract' is not defined. Any help?
8
9029
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 flexibility of showing text sometimes as well. Is there an easy way to get the text '0' or '1' instead of the CheckBox? My DataGridView is filled in with this basic code: DataTable dataTable = new DataTable(); qBindingSource.DataSource = dataTable;...
1
3777
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. Another combobox that shows the databases in that particular server. Another combobox with the filesets from the selected database above.
0
8866
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8550
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7385
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6192
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5663
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4366
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1772
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.