1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Creating/populating 2 Dim db for (2) dim array

Discussion in 'Software Development' started by leo1937ca, Dec 23, 2010.

Thread Status:
Not open for further replies.
Advertisement
  1. leo1937ca

    leo1937ca Thread Starter

    Joined:
    Dec 20, 2010
    Messages:
    3
    I have Created a program using vb6 which works fine in Windows 98 through Windows 2000, but as you know that there is no forward and backward compatibility between the cut-off points between Windows 2000 and Windows XP. I am attempting to convert the vb6 program to Visual Basic 2005 format for continued compatibility with newer Windows versions. Since My program is basically driven using the data from My database which was created using Access 2000 which does not translate to Visual Basic 2005 which uses Access 2002 through Access 2007 which I do not have. In the original program I created a Table in Access 2000 then copied the (2) digit string variables to (2) dimensional array where I manipulated the data and printed the revised data to a form. Since I down have the required Access program, I have decided to try creating the data base using a comma delimited text file (CSV) then copying the data to the (2) dimensional array. I have searched the Net for examples that can be used in vb 2005 express, but have not found anything that I can use. I need the code to create the Microsoft SQL Server database and a example of the code to copy that file to a (2) dimensional array whose dimensions are (10,60). The Numbers in the database are String Type to allow zeros as the first digit of single digit numbers and each record may have legal duplicates within the same record.

    Thank You for any help you provide

    leo1937ca
     
  2. DaBeers

    DaBeers

    Joined:
    Oct 30, 2008
    Messages:
    276
    This is an interesting problem and I like your willingness to rip the data into a format that is no longer dependent on the database. It sounds like it's small and a good solution. However, I do have a suggestion to the cvs format...why not XML? Both are fairly usable in other applications, but I think XML is easier to work with, as a raw datafile, until you get it back into a DBMS.

    With that said, the process it the same, you will need to organize the data by reading it from the old database, then output it into the new format. A data grid view does a good job of this. You can then iterate the data grid at you generate your output.

    Here is a good example of how to do it in cvs:
    http://p2p.wrox.com/vb-how/49414-how-do-i-export-data-dataviewgrid-csv.html

    Here is a very stripped down example of how to do it with XML:
    http://vb.net-informations.com/xml/create-xml-vb.net.htm
    (It can be elaborated on to remove the literals. Either one can be modified to render from an array.)

    GL,
     
  3. leo1937ca

    leo1937ca Thread Starter

    Joined:
    Dec 20, 2010
    Messages:
    3
    Thank You for your quick reply, your time and the example code. I will try to simplify what I think will
    work best for me. I am more familiar with vb6 than with Visual Basic 2005 or 2008 and the more code conversions I can use the easier the whole project will be. I have attached the code from Visual Basic 6 for the database Table example to this post. The code Opens the Database and reads the table data into a 2 dimensional array. I am using an Access 2000 Table that I converted to Access 2007 using Access 2007.If you could supply the equivalent code for Visual Basic 2005 and 2008 if different, It would be greatly appreciated. If I can get that working it would be a great help in getting started.

    Thank You in advance and for the help given already.

    Leo1937ca


    Public Sub DbaseReset()

    Dim cnt As New ADODB.Connection
    Dim combo As New ADODB.Recordset
    Dim db As String
    Dim LotNums(10,60)

    db = App.Path & "\Comb1A.mdb;" & "Provider=Microsoft.Jet.OLEDB.4.0;Mode=Read|Write"

    db = "Data Source= " & db
    cnt.Open db

    combo_Open "select * from bg50A", cnt

    For a = 1 To 10
    For b = 1 To 60
    LotNums(a, b) = combo(b - 1)
    Next
    combo.MoveNext
    Next
    combo.Close
    Set combo = Nothing
     

    Attached Files:

  4. DaBeers

    DaBeers

    Joined:
    Oct 30, 2008
    Messages:
    276
    So, if I understand right, you are not yet able to read the database into the array.

    I think the problem is in how you assign the record set to the array. Try replacing
    Code:
    [FONT=Arial]For a = 1 To 10[/FONT]
    [FONT=Arial][FONT=Arial]For b = 1 To 60[/FONT]
    [FONT=Arial]LotNums(a, b) = combo(b - 1)[/FONT]
    [FONT=Arial]Next[/FONT]
    [FONT=Arial]combo.MoveNext[/FONT]
    [FONT=Arial]Next[/FONT]
    [/FONT]
    with
    Code:
    LotNums = combo.GetRows()
    
    You shouldn't need to iterate as the whole record set will copied.

    Also, I found this website that seems to be discussing your same issue.
    http://www.dotnetspider.com/resources/1615-Convert-Recordset-array.aspx
    If I haven't hit the problem right on the head, maybe you can abstract more from that.

    GL,
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/970188

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice