![]() |
Click here to advertise with us
|
|
|||||||
| MS Access Related discussions using Access and JET as the backend |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hi.
When I add a new entry in a access database via the GUI, the vb.net program must be restartet before I can see the data in the GUI. 1. Why? 2. How to fix it? Thanks Code:
Dim cb As New OleDb.OleDbCommandBuilder(da)
Dim dsNewRow As DataRow
dsNewRow = ds.Tables("MyTabel").NewRow()
dsNewRow.Item("Email") = txtEmail.Text
dsNewRow.Item("Name") = txtName.Text
ds.Tables("MyTabel").Rows.Add(dsNewRow)
da.Update(ds, "MyTabel")
|
|
|||
|
I have allready looked there, because when I searched the forum, you have reply others with the same reply.
But there are a lot of walkthroughs. Can you point me to the right one? |
|
|||
|
No help in your links.
Maybe I didn't make myself clear, but I have made the vb.net application manualy, and not via the "drag'n drop" tools, becuase I need to show data in custom fields and controls. The above code updates the database with new information and stores it, but the new data is not shown in my application. I have to close the application and open it again, before the new data is shown. Somehow I need to "form_load" the entire application, without closing it or re-fresh the database via the application (I prefer the last option) |
|
||||
|
The data will be displayed in any controls that are bound to the DataTable you added the row to. If you're not seeing the data then I can only assume that you haven't bound that DataTable to any controls.
__________________
![]() 2007, 2008, 2009, 2010 Why is my data not saved to my database? | Communicating between multiple forms MSDN: Data Walkthroughs | "How Do I?" Videos My Blog: Custom Events | Dynamic GDI+ Drawing |
|
|||
|
Yes, I'm aware that if I follow the step-by-step solution, then It's working correct, but the reason for my post is that it's not working when I created the code myself, and I need help
![]() What I would like is the (I pretty sure it's simple) code for the dataset to update the database. Then Open() Close() to get the new database again, for display in the GUI. The problem is if I add this: Code:
Public Sub Database_load()
dbProvier = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
dbSource = "Data Source = C:\testDB.mdb"
con.ConnectionString = dbProvier & dbSource
con.Open()
sql = "SELECT * FROM SpilDATA"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "SpilDATA")
con.Close()
End Sub
Code:
Database_load() Code:
Dim cb As New OleDb.OleDbCommandBuilder(da)
Dim dsNewRow As DataRow
dsNewRow = ds.Tables("SpilDATA").NewRow()
dsNewRow.Item("SPIL") = txtSPIL.Text
dsNewRow.Item("CreatedBy") = txtCreatedBy.Text
dsNewRow.Item("Assign") = txtAssign.Text
dsNewRow.Item("Severity") = cboSeverity.Text
ds.Tables("SpilDATA").Rows.Add(dsNewRow)
da.Update(ds, "SpilDATA")
Database_load()
Then the records are dobble, in the GUI. ![]() Thanks. Last edited by thek; 07-08-2009 at 7:43 AM. |
|
|||
|
.....youre now complaining that....
I'm not complaning, I'm asking for help. ![]() I've ready your link, I've read the database sections in VB 2005 and VB for dummies, and servel articles on the net, but no luck. And what more confuses me, is that I have an EDIT and DEL button as well. When editing a record via gui, then it’s updated – without a new load from the database When deleting a record via gui, then it’s removed – without a new load from the database That's why I'm asking here. Last edited by thek; 07-08-2009 at 7:54 AM. |
|
||||
|
If you're loading the data in your Load event handler and you want to be able to load the data elsewhere too then just take the code out of the Load event handler and put it into a method that you can call from anywhere.
__________________
![]() 2007, 2008, 2009, 2010 Why is my data not saved to my database? | Communicating between multiple forms MSDN: Data Walkthroughs | "How Do I?" Videos My Blog: Custom Events | Dynamic GDI+ Drawing |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|