how to add,edit,save data in OLEDB

Yeung

Member
Joined
Jun 15, 2007
Messages
22
Programming Experience
Beginner
Hi, I've just established a connection to an access database using oledb data provider and was able to load all the information on a datagrid.

I was just wondering though, i have textboxes that lets a user enter info on them, how do i make these info inserted into the database and displayed on the datagrid? also how to edit,save and delete them from w/in vb.net

Thanks!
 
In VS 2003, u use currency managers, dataset and oledbdataadapters..


VB.NET:
dim cmProducts as currencyManager (GLOBAL VARIABLE)
'Delete
cmProducts.EndCurrentEdit()
cmProducts.RemoveAt(cmProducts.Position) 'the position of the datasource (i.e the row)

VB.NET:
'Add
cmProducts.EndCurrentEdit()
cmProducts.AddNew()

VB.NET:
'Update
 cmProducts.EndCurrentEdit()
If (DataSet11.HasChanges) Then
     OleDbDataAdapter1.Update(DataSet11, "Products")
DataSet11.AcceptChanges()
else
'show no changes detected message

VB.NET:
'Cancel edit
 cmProducts.CancelCurrentEdit()

to edit, nth is needed, after editing the user juz do click on the update button
 
VB.NET:
dim cmProducts as currencyManager (GLOBAL VARIABLE)
'Delete
cmProducts.EndCurrentEdit()
cmProducts.RemoveAt(cmProducts.Position) 'the position of the datasource (i.e the row)

There's a difference between remove and delete. Remove removes the local item, delete marks it for deletion in the database..
 
What I was trying to say is how to do these codes from VB6 in VB.NET

VB.NET:
'Add
Text1.Text=""
Text2.Text=""
Data1.Recordset.AddNew
'Save
Text1.Text=Data1.Decordset!name
Text2.Text=Data1.Recordset!passwd
Data1.Recordset.Update
'Delete
Data1.Recordset.Delete
 
(If you had .NET 2 it would be a little simpler)
sorry i went on vacation so it took me long to reply to this. i just got a cs from a friend containing .NET 2.0, VS2005 & SQL2005 EXPRESS. I might consider using it instead of .NET 1.1 if you (and i see a lot of people here) say it's a lot better and simpler to do this thing there.
 
Trust me, I've tried it in .NET 1.1 and it is sooo much simpeler in .NET 2.0.
You can drag and drop your items into the form and then you can immediately scroll, insert, delete and change records in your db without typing any code yourself.
 
by installing .NET 2.0 does it mean i also have to install VB 2005 Express? or I can use VS 2003 Enterprise Architect with .NET 2.0
 
by installing .NET 2.0 does it mean i also have to install VB 2005 Express? or I can use VS 2003 Enterprise Architect with .NET 2.0
you MUST install a 2005 variant of visual studio. 2003 does not produce .NET 2.0 exes, it does not have .NET 2.0 design features and it never, ever will have..
 
Back
Top