Adding New Records

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tigger
    New Member
    • May 2007
    • 37

    #1

    Adding New Records

    Hi there,
    I can already retrieve values from database (Microsoft Access). However, when i add new records, it won't be able to retrieve. Here's my codes:

    Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles Button1.Click

    Dim con As New OleDb.OleDbConn ection
    Dim ds As New DataSet
    Dim da As New OleDb.OleDbData Adapter
    Dim sql As String
    con.ConnectionS tring = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=D:\BIE\S owmya.mdb;Jet OLEDB:Database Password=****"

    con.Open()

    sql = "SELECT * FROM thresholdTable"
    da = New OleDb.OleDbData Adapter(sql, con)
    da.Fill(ds, "Sowmya")

    con.Close()

    s = Me.nameComboBox .SelectedIndex
    left250 = ds.Tables("Sowm ya").Rows(s).It em("AC250L")
    right250 = ds.Tables("Sowm ya").Rows(s).It em("AC250R")

    Me.Label1.Text = left250


    End Sub
  • richerTextBox
    New Member
    • Jan 2007
    • 15

    #2
    I may be able to help you. However, I don't understand what you are wanting to to do. Please rephrase your question.

    Comment

    • sumitbatra1981
      New Member
      • Aug 2007
      • 4

      #3
      This Code is fine for selection of records, i think u r not able to retrieve the records u have just added..
      You might not be refreshing ur datset after entering the record. which means u still have the old dataset.
      After Insertting, run this code again, then only u will able to get new records.

      Comment

      • tigger
        New Member
        • May 2007
        • 37

        #4
        Sorry for not making things clear. I have a combo box that contains 10 names. For eg. I select John's name. It will retrieve his left250 value. It will then compare this value with a variable called Count. I've managed to do this so far. However, when i add in a new name in the Access database, the name in the combo box does not appear. And when i delete John's name in the database, the name in the combo box will not be deleted. When i select John when i run the program, it will show error. I did not refresh cos i published the file into an executable file (i'm using visual basic 2005 express). I guess i need to add in some codes for my combo box. Cos when i retrieve values, it will retrieve in reference to the selected index of the combo box. How do i update my combo box automatically without having to refresh my vb program?


        s = Me.nameComboBox .SelectedIndex
        left250 = ds.Tables("Sowm ya").Rows(s).It em("AC250L")
        right250 = ds.Tables("Sowm ya").Rows(s).It em("AC250R")

        Comment

        Working...