Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Ok,Guys i try to exmplane you all steps for you understand what i`m doing and thanks for help.

I have a button import and when I click on it I get the data from all knuckles and enter them in the database, but nothing I want to be a box and the database does not introduce anything other stock exchange introduces. Like that

VB
Adapter.Insert(OrderCategory, _
                           SampleOrder, _
                            Requester, _
                                ProjectNumber, _
                                 CostCenter, _
                                  PersonInvoiced, _
                                   SampleCategory, _
                                    Quantity, _
                                     Nothing, _
                                      Description, _
                                       RecipientName, _
                                        DesiredDelivery, _
                                         AssemblyPlannedDate, _
                                          Coordonator, _
                                           ShippingMode, _
                                            ShippingAddress, _
                                             Urgent, _
                                              BOM, _
                                               Hazardous, _
                                                Transporter, _
                                                 SerialComponents, _
                                                  PrototypeComponents, _
                                                   ReadyAssembly, _
                                                   Status)



Ok, is perfect, i have all value in my database.
But when i try to fill al boxes with all value display that error.
Ok, i have a edit form where i try to fill all boxes and all DopDownList, but where is nothing (InvoiceValue) i want to put nothing in value for edit and update with another value.

Here is my code where i fill boxes.

VB
 Dim RowID As Integer = Nothing

        If GridView1.Rows.Count > 0 Then
            If GridView1.SelectedValue <> Nothing Then

                RowID = GridView1.SelectedValue

            End If
        End If

        Dim MyAdapter As New MV_SamplesOrdersTableAdapters.Orders_HeaderTableAdapter

        Dim DT As MV_SamplesOrders.Orders_HeaderDataTable = MyAdapter.GetDataByID(RowID)

If DT.Rows.Count > 0 Then
            BOX_SampleOrder1.Enabled = False

            DDL_OrderCategory1.Text = DT(0).OrderType
            BOX_SampleOrder1.Text = DT(0).DVMOrderNumber
            BOX_Requester1.Text = DT(0).Requester
            BOX_ProjectNumber1.Text = DT(0).ProjectNumber
            BOX_PersonInvoiced1.Text = DT(0).CostResponsable
            DDL_SampleCategory1.Text = DT(0).SampleOrderType
            BOX_Quantity1.Text = DT(0).TotalSamples
            BOX_CostCenter1.Text = DT(0).CostCenter

            If DT(0).InvoiceValue <> Nothing Then

                BOX_SampleInvoice.Text = DT(0).InvoiceValue

            End If
            BOX_Description1.Text = DT(0).OrderDescription
            BOX_RecipientName1.Text = DT(0).FinalCustomerAddress
            BOX_DesiredDelivery1.Text = DT(0).TargetDate
            BOX_AssemblyPlannedDate1.Text = DT(0).AssemblyPlannedDate
            DDL_Coordonator1.Text = DT(0).LogisticsResponsable
            DDL_ShippingMode1.Text = DT(0).ShippingMode
            DDL_Transporter1.Items.Clear()
            DDL_Transporter1.Items.Add(DT(0).ExpressShipment)

            BOX_ShippingAddress1.Text = DT(0).ShippingAddress
            DBL_Urgent1.Text = DT(0).Urgent
            RBL_Hazardous1.Text = DT(0).HazardousMaterial
            RBL_BOM1.Text = DT(0).HasBOM
            RBL_SerialComponents1.Text = DT(0).HasSerialComponents
            RBL_PrototypeComponents1.Text = DT(0).PrototypeComponents
            RBL_ReadyAssembly1.Text = DT(0).ReadyForAssembly
            DDL_Status1.Text = DT(0).Status

        End If


Here display my error, where i have "if" is a problem. Is <> Nothing, but my problem is to fill that box with nothing or jump this step. Thanks
Posted
Comments
F-ES Sitecore 4-Sep-15 3:48am    
google "dealing with dbnull vb.net" and you'll find explanations and solutions to this.

1 solution

Try

VB
If DT(0).InvoiceValue IsNot Nothing Then


?
 
Share this answer
 
Comments
MoraruVladut 4-Sep-15 3:48am    
Error 1 'IsNot' requires operands that have reference types, but this operand has the value type 'Decimal'.

My invoiceValue in database is type decimal.
Duncan Edwards Jones 4-Sep-15 3:51am    
OK - so it can never equal "Nothing". Therefore you need to check if the field is null and only if not then try and set the value. Do what F-ES Sitecore suggested.
MoraruVladut 4-Sep-15 4:14am    
Yes, i need to check if is in database the value iss nul, but how? When i try display same error
MoraruVladut 7-Sep-15 7:47am    
Try and catch is the solution, display error but continue.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900