Learn how to a build a cloud-first strategyRegister Now

x
?
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
?
212 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month20 days, 23 hours left to enroll

810 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