Click here to Skip to main content
15,878,959 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi to all.

I have write the code in the end to fill manually 1 datagridview...
I need some help for add delete and update this datagridview...

Thanks and regards......

VB
Imports System.Data.OleDb
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim Con As OleDbConnection
        Dim sqlCmd As OleDbCommand = New OleDbCommand("select * from Movement_roller_H")
        Dim myData As OleDbDataReader
        Con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source =C:\Users\Louisa\Desktop\Roller.mdb")
        Con.Open()
        sqlCmd.Connection = Con
        myData = sqlCmd.ExecuteReader

        Do While myData.Read
            Dim dgRow As New DataGridViewRow()
            dgRow.CreateCells(DataGridView1)
            dgRow.Cells(0).Value = myData.GetInt32(0)
            dgRow.Cells(1).Value = myData.GetDateTime(1).ToString("d")
            dgRow.Cells(2).Value = myData.GetString(2)
            Dim strValue3 As String = IIf(myData.IsDBNull(3), "", myData.GetValue(3))
            dgRow.Cells(3).Value = strValue3
            dgRow.Cells(4).Value = myData.GetDateTime(4).ToString("d")
            DataGridView1.Rows.Add(dgRow)
        Loop
    End Sub
End Class
Posted

This[^] may help you.

It has the example with the source code. Hope it would be helpful to you for understanding the operations related to the grid. Additionally it includes paging also.
 
Share this answer
 
Comments
Sandeep Mewara 25-Apr-11 11:15am    
Comment from OP:
Something in VB????????????????
That's Aragon 26-Apr-11 4:06am    
Sandeep , Thank you for noticing the language difference. OP can use http://www.developerfusion.com/tools/convert/csharp-to-vb/ to convert and understand the syntax.
Sandeep Mewara 26-Apr-11 4:31am    
hey that was not my comment... it was OP's.

From my side, C# or Vb, links were enough to move ahead in a given direction. :)
on button event you write:
this is for selected row to remove!


datagridview1.rows.remove(datagridview1.curentrow)



to manipulate in easy way with database is using Table adapter manager! you can easy create querys
Delete
Update
Insert INTO
Scalar Queries!
 
Share this answer
 
This[^] could help you.
 
Share this answer
 
Comments
Sandeep Mewara 25-Apr-11 11:14am    
Comment from OP:
Something in VB????????????????

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