PC Review


Reply
Thread Tools Rate Thread

Add to a database of a 2nd Form

 
 
DINESH PATEL
Guest
Posts: n/a
 
      11th Dec 2005
I have no problems adding, deleting or editing data from a database when
these functions are on the 1st form. I need these functions on the 2nd form
though, as the 1st form will be a Menu screen.

Public Class Form2

Inherits System.Windows.Forms.Form

Dim con As String = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source =
C:\TravelAgents.mdb"

Dim sqlStr As String = "SELECT * FROM Members"

Dim oleDbMembersAdapter As New OleDb.OleDbDataAdapter(sqlStr, con)

Dim oDataTable As New DataTable



Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

oleDbMembersAdapter.Fill(oDataTable)

End Sub



Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAdd.Click

Dim MyNewRow As DataRow = oDataTable.NewRow

Dim changes As Integer

Dim commandbuilder As New OleDb.OleDbCommandBuilder(oleDbMembersAdapter)



MyNewRow("Forename") = txtForename.Text

oDataTable.Rows.Add(MyNewRow)

changes = oleDbMembersAdapter.Update(oDataTable)

MsgBox("Sucess")



End Sub

End Class

This however does not work when i try to add off the 2nd form highlighting
'changes = oleDbMembersAdapter.Update(oDataTable)' as a problem. The only
code on the 1st form is the btnNext code, only a navigational button. Would
I need anymore code on form 1 or form 2 (above).


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy table form BE database to BE database Cesar Microsoft Access VBA Modules 2 19th Aug 2008 01:32 AM
Link form another database table into current database Anna Microsoft Access Forms 2 16th Aug 2006 08:57 PM
saving data from a form in one database into another database chummy via AccessMonster.com Microsoft Access Form Coding 1 24th May 2006 04:00 PM
Question re: locks in split database - form level and database lev =?Utf-8?B?QW1pdA==?= Microsoft Access Form Coding 0 11th Jul 2005 11:51 PM
Form in backend database creates new user in frontend database =?Utf-8?B?Sm9uYXRoYW4gQnJvd24=?= Microsoft Access Security 6 23rd Jan 2005 03:04 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:33 PM.