Results 1 to 3 of 3

Thread: [RESOLVED] Can not save data MS Access ?

  1. #1

    Thread Starter
    Addicted Member Tengkorak's Avatar
    Join Date
    Nov 2006
    Posts
    240

    Resolved [RESOLVED] Can not save data MS Access ?

    hi,

    i have problem when save data at ms access database (save multiple data)
    hire my code :
    VB.NET Code:
    1. Dim prodid As String
    2.             Dim charga As Double = 0
    3.             Dim iqty As Double = 0
    4.             Dim idisc As Double = 0
    5.  
    6.             'simpan detail
    7.             For i As Integer = 0 To dg.Rows.Count - 1
    8.                 If dg.Item(0, i).ToString.Trim <> "" And _
    9.                         dg.Item(1, i).ToString.Trim <> "" Then
    10.  
    11.                     prodid = dg.Item(0, i).ToString
    12.                     charga = IFValNull(dg.Item(3, i).Value)
    13.                     iqty = IFValNull(dg.Item(4, i).Value)
    14.                     idisc = IFValNull(dg.Item(5, i).Value)
    15.  
    16.                     Dim scmd2 As New OleDb.OleDbCommand
    17.  
    18.                     scmd2.CommandText = "insert into inv_t_po_details(orderno,prod_id,orderprice,orderqty,discount)values" & _
    19.                                     "(@orderno,@prod_id,@orderprice,@orderqty,@discount)"
    20.  
    21.                     scmd2.Parameters.AddWithValue("@orderno", nopo)
    22.                     scmd2.Parameters.AddWithValue("@prod_id", prodid.ToString)
    23.                     scmd2.Parameters.AddWithValue("@orderprice", 0)
    24.                     scmd2.Parameters.AddWithValue("@orderqty", 0)
    25.                     scmd2.Parameters.AddWithValue("@discount", 0)
    26.  
    27.                     scmd2.Connection = GetConnection()
    28.                     scmd2.ExecuteNonQuery()
    29.  
    30.                 End If
    31.             Next

    error :
    Code:
    The field is too small to accept the amount of data you attempted to add. Try inserting or pasting less data

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Can not save data MS Access ?

    Does the error message not speak for itself? One of the values that you're trying to save is too big for the column you're trying to save it to.

  3. #3

    Thread Starter
    Addicted Member Tengkorak's Avatar
    Join Date
    Nov 2006
    Posts
    240

    Re: Can not save data MS Access ?

    thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width