Solved

How to convert the .xsl files or .txt file  data into .mdb file through vb programming?

Posted on 2001-06-20
6
204 Views
Last Modified: 2010-05-02
For this ...Iam creating DSN for excel or txt
i have DSN for .mdb

i used the following code
for ex: my txt files
Customer name      Address
Rajani              XXXX
but iam getting the whole line value into rs(0).But i want rs(0) as Rajani and rs(1) as XXXX

how?can u suggest some sample codes?

Rgds,
Rajani

Private Sub chgdata()
 Dim conn As adodb.Connection
     Dim cmd As adodb.Command
    Dim rs As adodb.Recordset
    Set rs = New Recordset
    Set conn = New Connection
     conn.Open "dsn=txtacr"
    mysql = "select * from acrtest.csv"
    rs.Open mysql, conn, adOpenDynamic
    rs.MoveFirst
     Set cmd = New Command
   cmd.ActiveConnection = MDIForm1.dfwConn
   Do While Not rs.EOF
   insql = "insert into cust values('" & rs(0) & "','" & rs(1) & "')"
   MDIForm1.dfwConn.Execute insql

rs.MoveNext
Loop

End Sub
0
Comment
Question by:rajani50
6 Comments
 
LVL 6

Expert Comment

by:simonbennett
ID: 6209797
Hi

Which database are you inserting into?

Simon
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 6209808
<wispering to simonbennett>
MSAccess (read the q-title: .mdb)
</wispering to simonbennett>

0
 
LVL 6

Expert Comment

by:simonbennett
ID: 6209832
<clearsthroat humble=true>

I suppose that means DTS is out of the question then.

Is the file coming from a unix source? If so the row terminators will be different. I would suggest reading the file with the FSO or with OPEN FOR READ, LINE INPUT methods.

HTH

Simon
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 2

Expert Comment

by:damienm
ID: 6210935
If your file is delimited in some way then you it is ok to get a row at a time, then you can format the data into the correct parts.

Then use something like

insql = "insert into cust values('" & trim(left(str,6) &  & "','" & trim(instr(str,6,8)) & "')" etc.
  MDIForm1.dfwConn.Execute insql

0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7139573
Hi rajani50,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will suggest to:

    Save as PAQ -- No Refund.

EXPERTS: Post a comment if you are certain that an expert deserves credit.  Explain why.
==========
DanRollins -- EE database cleanup volunteer
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 7173357
Question placed in PAQ

Computer101
E-E Moderator
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

827 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question