inserting records into database 
Author Message
 inserting records into database

I have an access 2000 database with one table, in wich I want to insert
records.

What is the least memory taking way to do this ?

Thx in advance,

-------------
Tom Deseyn



Mon, 03 Jan 2005 16:40:44 GMT  
 inserting records into database
Hi Tom,

I like an Insert query in this situation. Here's an example starting from an
existing connection (bpConnection):

Dim bpCommand As OleDbCommand
Dim columnList As String = "readingDate, readingTime, bpSystolic, " _
 & "bpDiastolic"
Dim valueList As String = BuildValueList(BPDate.Text, BPTime.Text, _
 BPSystolic.Text, BPDiastolic.Text)
Dim sqlInsert As String = String.Concat("INSERT INTO bpReadings (", _
 columnList, ") Values (", valueList, ")")

bpConnection.Open()
bpCommand = New OleDbCommand(sqlInsert, bpConnection)
bpCommand.ExecuteNonQuery()

Private Function BuildValueList(ByVal ParamArray valueArray() As _
 String) As String

 Dim returnString As String
 Dim strVal As String

 For Each strVal In valueArray
  strVal = String.Concat("'", Replace(strVal, "'", "''"), "'")
  If returnString = "" Then
   returnString = strVal
  Else
   returnString = String.Concat(returnString, ",", strVal)
  End If
 Next
 Return returnString
End Function

HTH,

--
Jeff Rhodes
Author of "VBTrain.Net: Creating Computer and Web Based Training with Visual
Basic? .NET"
www.vbtrain.net
Home of the Shape and Graphical Text controls


Quote:
> I have an access 2000 database with one table, in wich I want to insert
> records.

> What is the least memory taking way to do this ?

> Thx in advance,

> -------------
> Tom Deseyn



Mon, 03 Jan 2005 21:21:47 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. How to improve speed of inserting record into database

2. How to insert records in database from webpages

3. inserting multiple records into a database..

4. Access Database, INSERTING a record raises an error

5. Inserting Records in Access95 database through VB5.....

6. insert records into remote access database throught rdo

7. Inserting records from one database table to another in SQL Server

8. Inserting Records into a Microsoft Access Database inside a Loop

9. Can VB4 database insert records??

10. Insert multiple records in a database using vbscript

11. Insert Record to Access Database

12. Insert records into another Database?

 

 
Powered by phpBB® Forum Software