Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Access VB.NET DataGridView , +
Hello
I make function to save data from datagridveiw to Access data Base
 

Private Function SD()
    Dim I As Integer
    For I = 0 To Me.DataGridView1.Rows.Count - 1
        Me.VendorLongBillTableAdapter1.Insert(Me.DataGridView1.Item(0, I).Value, Me.DataGridView1.Item(1, I).Value, Me.DataGridView1.Item(2, I).Value, Val(Me.DataGridView1.Item(3, I).Value), Val(Me.DataGridView1.Item(5, I).Value), Val(Me.DataGridView1.Item(4, I).Value) * Val(Me.DataGridView1.Item(3, I).Value), Val(HowIPaid.Text), Val(HowStill), Me.DataGridView1.Item(7, I).Value, Convert.ToDateTime(Me.DataGridView1.Item(6, I).Value))
        'TODO: This line of code loads data into the 'RAFAADataSet.Prudects' table. You can move, or remove it, as needed.
    Next
End Function
 
but when I use this function error happened
 
Argument 'Expression' cannot be converted to type 'TextBox'
 
where is the error ?
Posted 14-Jan-13 3:51am
kosay851.3K

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Looks like this is the cuplprit:
Val(HowStill)
It looks that HowStill is a textbox control. You might need to do:
Val(HowStill.Text)
  Permalink  
Comments
Maciej Los at 14-Jan-13 10:51am
   
Moved from answer:
the value I have insert is String not double so if I input
val(HowStill.txt) it will return it to value = 0
 
kosay85
Sandeep Mewara at 14-Jan-13 13:03pm
   
Thanks Maciej.
 
To OP:
Then simply put: HowStill.Text
 
If you know that you need text then how can you provide a control object instead of a value?! :doh:
Maciej Los at 14-Jan-13 14:36pm
   
Eagle-Eye, +5!
Sandeep Mewara at 15-Jan-13 8:04am
   
Thanks Mac. :)

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

  Print Answers RSS
0 DamithSL 265
1 CPallini 235
2 OriginalGriff 233
3 Maciej Los 175
4 George Jonsson 170
0 OriginalGriff 5,305
1 DamithSL 4,382
2 Maciej Los 3,760
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,901


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 22 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100