Solved

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

Posted on 2001-06-20
6
205 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…

730 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