Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 150,065 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,779 people online right now. Registration is fast and FREE... Join Now!




data not stored

 
Reply to this topicStart new topic

data not stored

a_a_s
6 Mar, 2008 - 11:30 AM
Post #1

D.I.C Head
**

Joined: 20 Feb, 2008
Posts: 67

no error in code but the data is not stored in the db
CODE

con.Open()

        Dim sql As String = "SELECT * FROM [Section]"
        Dim da As New OleDbDataAdapter(sql, con)
        Dim ds As New DataSet
        da.Fill(ds, "Section")
         Dim dsNewRow As DataRow
        dsNewRow = ds.Tables("Section").NewRow()
        dsNewRow.Item("Group") = Form1.ComboBox2.Text
        dsNewRow.Item("CourseID") = Form1.ComboBox3.Text
        dsNewRow.Item("SectionID") = Form1.TextBox1.Text
        dsNewRow.Item("Type") = Form1.ComboBox47.Text
        da.Update(ds, "Section")
        con.Close()


and i want to ask if i can change the textbox in loop
ex. textbox&i.text and i change the value of i during the loop
User is offlineProfile CardPM
+Quote Post

Jayman
RE: Data Not Stored
6 Mar, 2008 - 12:28 PM
Post #2

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 7,319



Thanked: 66 times
Dream Kudos: 500
Expert In: Everything

My Contributions
You forgot to add the row to the dataset just before Update is called.
CODE

con.Open()

        Dim sql As String = "SELECT * FROM [Section]"
        Dim da As New OleDbDataAdapter(sql, con)
        Dim ds As New DataSet
        da.Fill(ds, "Section")
         Dim dsNewRow As DataRow
        dsNewRow = ds.Tables("Section").NewRow()
        dsNewRow.Item("Group") = Form1.ComboBox2.Text
        dsNewRow.Item("CourseID") = Form1.ComboBox3.Text
        dsNewRow.Item("SectionID") = Form1.TextBox1.Text
        dsNewRow.Item("Type") = Form1.ComboBox47.Text
        ds.Tables("Section").Add(dsNewRow)
        da.Update(ds, "Section")
        con.Close()


User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 10:48PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month