Subscribe to Vishal1419's Blog        RSS Feed
-----

Add Multiple Rows to Database in VB.Net

Icon Leave Comment
Hello Friends,

dim sql as string
dim da as oledb.oledbDataAdapter
dim ds as new dataset

con.open()

sql = "SELECT * FROM tblFruits"
da = new oledb.oledbDataAdapter(sql,con)
da.update(ds,"tblFruits")

con.close()

dim cb as new oledb.oledbCommandBuilder(da)
dim i as integer
dim dsNewRow (0 to 4) as DataRow

for i = 0 to 4

       dsNewRow(i) = ds.Tables("tblFruits").NewRow()

       if i = 0 then
           dsnewrow(i).Item("FruitName") = "Mango"
       elseif i = 1 then
           dsnewrow(i).Item("FruitName") = "PineApple"
       elseif i = 2 then
           dsnewrow(i).Item("FruitName") = "Chikoo"
       elseif i = 3 then
           dsnewrow(i).Item("FruitName") = "Apple"
       elseif i = 4 then
           dsnewrow(i).Item("FruitName") = "Banana"
       End If

       ds1.Tables("tblFruits").Rows.Add(dsnewrow(i))

       da1.Update(ds1, "tblFruits")

Next i

0 Comments On This Entry

 

Trackbacks for this entry [ Trackback URL ]

There are no Trackbacks for this entry

August 2014

S M T W T F S
     12
3456789
10111213141516
1718192021 22 23
24252627282930
31      

Tags

    Recent Entries

    Search My Blog

    0 user(s) viewing

    0 Guests
    0 member(s)
    0 anonymous member(s)

    Categories