robo100
Member
Ok this is a newbie question so I apploigize in advance. I have done quite a few programs with Visual Basic (actually since version 1.0) and I have used version 6.0 for the longest time, however I have a very large application that I am writing in Visual Studio 2005. This application is going to have several databases, which I know nothing about. I gave it a try and just can't seem to get anyplace or find simple examples.
I created a simple access 2000 database (users.mdb) with 2 records in it. I then created a table (userstable) in that database. I also created a query called fillbyuser. In my code during the load procedure I did this:
UsersTableAdapter.FillByuser(UsersDataSet.users)
Dim newitem As Integer
filteredview = userstable
filteredview.RowFilter = "user Like '%" + "" + "%'"
cnt = filteredview.Count
newitem = 0
'fill combobox with users
Do Until newitem = cnt
user_combo.Items.Add(filteredview.Item(newitem)("user"))
newitem = newitem + 1
Loop
user_combo.SelectedIndex = 0
Also I set all the text fields on the form with the data by doing adding statements for each text box:
txtuser.Text = filteredview.Item(cnt)("user")
I know this code is really simple it just reads the usertable and puts all users in a combobox. I modified this code slightly to provide a search function based on the user field. This all seems fine and dandy but I can't figure out how to write changes, add new records, delete records. I have seen posts that people are using the INSERT TO or tabeadapter.update but have not figured out how to do it. I tried the following on a Update command button
If UsersDataSet.users.GetChanges() IsNot Nothing Then
Me.UsersTableAdapter.Update(UsersDataSet.users.GetChanges())
Label5.Text = "Udated"
End If
Still no go. The code does not generate any errors it just doesnt work. I even tried making the text boxes linked to certain fields by clicking and dragging the fields and dropping them into the text boxes, of course this works as far as getting the data from the database but it doesnt help the above code. As I understand it I need to make changes to the table adapter and do an update, then the database file will be update (or whatever database is binded to the adapter) is this correct?
I know this is a really newbie question and I would appreciate any help or suggestions for books, webpages that may help me out.
I created a simple access 2000 database (users.mdb) with 2 records in it. I then created a table (userstable) in that database. I also created a query called fillbyuser. In my code during the load procedure I did this:
UsersTableAdapter.FillByuser(UsersDataSet.users)
Dim newitem As Integer
filteredview = userstable
filteredview.RowFilter = "user Like '%" + "" + "%'"
cnt = filteredview.Count
newitem = 0
'fill combobox with users
Do Until newitem = cnt
user_combo.Items.Add(filteredview.Item(newitem)("user"))
newitem = newitem + 1
Loop
user_combo.SelectedIndex = 0
Also I set all the text fields on the form with the data by doing adding statements for each text box:
txtuser.Text = filteredview.Item(cnt)("user")
I know this code is really simple it just reads the usertable and puts all users in a combobox. I modified this code slightly to provide a search function based on the user field. This all seems fine and dandy but I can't figure out how to write changes, add new records, delete records. I have seen posts that people are using the INSERT TO or tabeadapter.update but have not figured out how to do it. I tried the following on a Update command button
If UsersDataSet.users.GetChanges() IsNot Nothing Then
Me.UsersTableAdapter.Update(UsersDataSet.users.GetChanges())
Label5.Text = "Udated"
End If
Still no go. The code does not generate any errors it just doesnt work. I even tried making the text boxes linked to certain fields by clicking and dragging the fields and dropping them into the text boxes, of course this works as far as getting the data from the database but it doesnt help the above code. As I understand it I need to make changes to the table adapter and do an update, then the database file will be update (or whatever database is binded to the adapter) is this correct?
I know this is a really newbie question and I would appreciate any help or suggestions for books, webpages that may help me out.