Results 1 to 7 of 7

Thread: [2008] save to an access database

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2007
    Location
    indiana
    Posts
    341

    [2008] save to an access database

    Hello,

    I have a database with street addresses in it. I built a program that submits the addresses to whitepages.com. Then I added some code to get the phone number from whitepages.com and put it in a text box. Now I need to save that to the access database. In my data base there are 7 columns. One for address,city,state,zip,name,phone #,auto number. I need to save the phone number in the phone # column in the same row as the address that was used to retrieve it from whitepages.com. So if the phone # is (222)333-4444 then I don't want that to be stored in a new row (so far that is the only way I have found to do it).

    I would appreciate your help very much

  2. #2
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,160

    Re: [2008] save to an access database

    There is possibly a better way of doing this but here goes.

    I load the listview's selected row (which is filled from a access data base) onto a second form that has 6 textbox's and delete the selected listview's row.
    Code:
        Try
                Edit.txtComponentName.Text = Me.ListView1.SelectedItems(0).Text
                Edit.txtMaterial.Text = Me.ListView1.SelectedItems(0).SubItems(1).Text
                Edit.txtLengthSize.Text = Me.ListView1.SelectedItems(0).SubItems(2).Text
                Edit.txtQuantity.Text = Me.ListView1.SelectedItems(0).SubItems(3).Text
                Edit.txtlmNo.Text = Me.ListView1.SelectedItems(0).SubItems(4).Text
                Edit.txtNotes.Text = Me.ListView1.SelectedItems(0).SubItems(5).Text
                Edit.Show()
            Catch ex As Exception
                MsgBox("Select a Component to Edit First")
                Exit Sub
            End Try
            'delete selected listview row
            For i As Integer = Me.ListView1.SelectedItems.Count - 1 To 0 Step -1
                Me.ListView1.Items.Remove(Me.ListView1.SelectedItems(i))
            Next i
    I edit the textbox (this is where you could load the phone number into one) then save back to the listview
    Code:
          With frmMaterialList.ListView1.Items.Add(Me.txtComponentName.Text)
                .SubItems.Add(Me.txtMaterial.Text)
                .SubItems.Add(Me.txtLengthSize.Text)
                .SubItems.Add(Me.txtQuantity.Text)
                .SubItems.Add(Me.txtlmNo.Text)
                .SubItems.Add(Me.txtNotes.Text)
            End With
            Me.Close()
    HTH

    ps, any chance of seeing the code you used to get the phone number

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2007
    Location
    indiana
    Posts
    341

    Re: [2008] save to an access database

    I will try the code and upload the "phone numeber getter" code. cause it is getting really late here.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,302

    Re: [2008] save to an access database

    Follow the Data Access link in my signature to see some ADO.NET code examples. The one to interest you is the one that retrieves, edits and saves data. You are already getting the address from a row in the database so you already know EXACTLY which row to update. Once you get the phone number you simply assign the value to the appropriate column of the very same row you got the address from in the first place. Once you've got all the phone numbers you need you save the changes back to the database.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2007
    Location
    indiana
    Posts
    341

    Re: [2008] save to an access database

    Is it possible to use
    Code:
    DataSet1.table.column.Caption = TextBox1.Text
    Is there a way to make that work?

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,302

    Re: [2008] save to an access database

    vb.net Code:
    1. myDataSet.Tables(tableIndex).Columns(columnIndex).ColumnName = columnName

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2007
    Location
    indiana
    Posts
    341

    Re: [2008] save to an access database

    thanks but i think i will just save it to a text file as index,phone# then improt it into access later.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width