Click here to Skip to main content
15,893,814 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hello guys
i just made some code to bind Datagridview with Adodb but i cannot add an empty rows to the grid!

VB
Imports ADODB
Imports System.Data.OleDb

Public Class Form1
    Dim Cntemp As New ADODB.Connection
    Dim Rstemp As New ADODB.Recordset
    Dim Dataset1 As New DataSet
    Dim DataAdapter1 As New OleDbDataAdapter

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Cntemp.Open("Provider=Microsoft.ace.OLEDB.12.0; Data Source=" & Application.StartupPath & "\vbdata.accdb")
        Rstemp.Open("Select * From tbltemp", Cntemp, 1, 2)

        DataAdapter1.Fill(Dataset1, Rstemp, "tbltemp")
        dgv.DataSource = Dataset1.Tables(0)
        dgv.Rows.Add(10)
        
    End Sub
Posted

 
Share this answer
 
Comments
Bass Alfan 17-Feb-15 2:03am    
oh oh /\jmot
actually i didn't get ur point!
/\jmot 17-Feb-15 2:24am    
dgv.Rows.Add(10) is not right.
dgv.Rows.Add(dr);//where dr is a DataRow

See Here
you cant call dgv.Rows.Add(10)

you need to declare a new datarow e.g.


VB
Dim dr As DataRow = dataset1.Tables(0).NewRow
dgv.rows.add(dr)
 
Share this answer
 

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