1.11M Members

Beginner: how to add new record into database???

 
0
 

Hi all, i am a new to VB.NET and i have a project to be completed urgently.
I need to insert information from textboxes into a database, I have created the connection using Jet Engine, the connection is working well because I can display records. However I cannot insert new records, it seems that the data adapter is not updating the database.
This is the insert code that I used:
Me.BindingContext(DsAccount1, "Account").AddNew()

Can you help me using a simple ex please!!

Suppose that name of dataset is dsAccount, the table has two fields called Username and Password, and the textboxes are txtUserName and txtPassword. The button to add new record is btnAdd

Please can anyone tell me how to do it??

 
0
 

why don't you have a look at this link

 
0
 

Steven,
u can use this code to add record to a database

Private Sub B1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B1.Click
dim con As New ADODB.Connection

        Dim tmp As New ADODB.Recordset
        Dim s As String

        con.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=K:\Database\db1.mdb"
        con.Open()
        s = "select * from add1"
        tmp.Open(s, con, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)
        tmp.Update()
        MsgBox("Record Saved")
Exit Sub
 
0
 

Hey thanks all of you. I will try them and let you know, I'm sure it will work.
thx again :)

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article