Link to home
Start Free TrialLog in
Avatar of blue021097
blue021097

asked on

Strings to MS Access Database

I have 3 strings (sA, sB, sC) with some content.

I would like to know how to insert these strings in a MS Access
Database in the following manner.

Col 1 = sA
Col 2 = sB
Col 3 = sC

Do you know what I mean?

Avatar of Marine
Marine

Are these 3 strings different fields ? Or these strings one field ? Which must be inserted into one field ? Here is some sample code. This uses OLEDB provider.

Dim Cn as New ADODB.Connection
Dim sCon as string,sSql as string
sCon = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\my documents\mb.mdb;"
Cn.Open scon
Col1 = sA
Col2 = sB
Col3 = sC
sSql = "Insert Into <tablename> Values ('" & col1 & "','" & col2 & "','" & col3 & "')"
Cn.Execute sSql,adExecuteNoRecords
cn.close
Set cn = nothing
This code will insert records into 3 fields. Explain me if this is not what you looking for.
ASKER CERTIFIED SOLUTION
Avatar of eab111098
eab111098

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Dude its not necessary to lock the question. If it will be the right answer he can accept your comment. If the question is locked others can't see it since most of them don't browse answered question. I beat your time though :-) i got my answer in first. Blue my example uses ADO method of access his example uses DAO you havent' specified what you were using. My method would be faster for one reason only. It uses SQL to update and it doesn't create a recordset which is a plus.
Avatar of blue021097

ASKER

Marine,

Your answer may very well be right but I have
accepted eab answer as it is the first
I tried out, and it worked. Problem solved.

I hope this is okay?