?
Solved

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

Posted on 2001-06-20
6
Medium Priority
?
208 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month13 days, 3 hours left to enroll

777 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