-
I need some help.
I have been able to read in each line from a text file and format it correctly. Each line contains six value, i have got these stored in a string/int variables.
What is the best way to write these to my table in an access/sql database.
I can open the connection to the database etc its just the writing to a specific table.
Any ideas??????
-
Hi, here is what we do in Visual Basic.
1) This uses DAO...
--code--
dim db as database
dim rs as recordset
dim strquery as string
set db = opendatabase("Your database complete path")
strquery = "Select * from <your tablename> "
set rs = db.openrecordset(strquery)
--adding a record to the table--
--for this add a record to the recordset instead--
--firstly check if the table is empty--
if not rs.recordcount = 0 then
rs.movelast
rs.movefirst
end if
--now add a new record--
if not rs.recordcount = 0 then
rs.addnew
rs(0) = yourvariable1
rs(1) = yourvariable2
...
...
rs.update
end if
--thats it you have now added a record to ur table--
2) The code would be similar if u r using ADO but the only change probably would be setting the connection instead of using opendatabase...
all the best...vijay
-
Insert data...
Use the INSERT.... VALUES SQL syntax.
Cheers,
Paul