Jump to content

..:: Creating new row ::..

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
5 replies to this topic

#1
bahrain

bahrain

    Newbie

  • Members
  • PipPip
  • 23 posts
Hello Folks ,,

i'v a simple question,, how can I add a row to an Access database in run time ,,
I mean what is the code for creating a new record..

thanx in advance

#2
Guest_Jordan_*

Guest_Jordan_*
  • Guests
The SQL is

INSERT INTO <table> (<colname>,<colname>,<colname>, etc) VALUES('value1','value2','value3','etc);


#3
bahrain

bahrain

    Newbie

  • Members
  • PipPip
  • 23 posts
thanx man ,

but I'm using Access

#4
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Can you not do SQL with Access?

#5
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
Are you using ADO.NET in VB then? You can certainly use SQL.
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#6
kadosh1000

kadosh1000

    Newbie

  • Members
  • Pip
  • 4 posts
Option Strict Off
Option Explicit On
Public Class Form1
dim a, b, c as string
Dim DataBase As dao.Database
Dim Table As dao.Recordset
Dim OpenDataBasee As New dao.DBEngine
a = textbox1.text
b = textbox2.text
c= textbox 3.text

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        DataBase = OpenDataBasee.OpenDatabase("Your's Database Path")
        Table = DataBase.OpenRecordset("Your Table Name")
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Table.addNew()
        Table.Fields("How ever you called the firs column").Value = a
        Table.Fields("How ever you called the second column").Value = b
        Table.Fields("How ever you called the third column").Value = c
End Sub

End Class

Edited by Jordan, 23 January 2009 - 03:16 PM.