Convert Access database to VB project


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Page 1 of 4 123 ... LastLast
Results 1 to 15 of 52

Thread: Convert Access database to VB project

  1. #1
    Join Date
    Dec 2006
    Posts
    49

    Unhappy Convert Access database to VB project

    Hi
    I am a new bee here and i am in a great problem. Well I am doin a project in which i need to search the co-ordinate of Y-axis for given X- axis from many tables.

    I have the data for x and y values for each table. Now I want to create a database in Microsoft access and upload it in my project so that when i convert my project to exe it can work in any computer.

    If any one can give me a detailed procedure I will be very thankful to him.

    Tava

  2. #2
    Join Date
    Aug 2004
    Location
    Orange, California
    Posts
    1,263
    There are lots of methods for doing this. Your question is not very clear. If all you have are x and y values in each table then you could load the values in by importing data files, or keying them in manually. If they are already in text files you could use ADO with the text provider and not even use Access at all. Just keep the data in the text files. Once you decide where the data is to be stored then you can open a recordset object using SQL statements to locate the records that you want. Example SQL: Select Y From mytable Where X = 10;
    This example would give you a recordset with the Y field of every record from the table called mytable where the X field is equal to 10.

  3. #3
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    First u must provide near your exe file the database file which containes your tables data ..
    Uploading all the tabels data into your exe [like puting it as resource] will not be effective if you want to edit them after that , or it will keep a very large amount of memory every time you want to make any thing on them [not at all effective] ..
    Usually we make a database conection like ADO as Ron mentioned , you can add it from your application refrence ,, and as I told u , you will have an exe file and a database file that can runs fine together in any computer .
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  4. #4
    Join Date
    Dec 2006
    Posts
    49
    thanx for your reply.

    well I think i need to explain my work properly.

    i have variables Gh, Cp, Fn,Cr

    there are nine sheets for different gh values.
    Gh: 4 4.5 5 5.5 6 6.5 7 7.5 8

    for each Gh value there are 20 Cp curves with X axis for Fn values and Y axis for Cr values.

    Now I need to find out Cr value for a given Gh value at a specific Cp curve in a Gh sheet.


    This may be very confusing but i have tried my best to explain the problem statement. (I have 9 sheets of paper. in each paper 20 curves(one each for Cp) of Cr(Y axis) vs Fn(X axis).




    Now if you can please tell me how to proceed I can start working on that.

    Please explain how to import or every thing because i am new in VB as well as never used access or SQL. I just need this thing done.please help.

    thanx

    tava

  5. #5
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    Where u save them ? in access database ? in exel sheets ? how is your tabels then ?
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  6. #6
    Join Date
    Dec 2006
    Posts
    49

    Arrow

    Can you tell me which one will be best option for me. if i do it in excell there will be lots of files. so i think acces will be better( as said by access tutorials). where should i keep the access file? and what to do with it?
    waiting for reply.

  7. #7
    Join Date
    Dec 2006
    Posts
    49
    you can mail me the procedure( it must be big) in my email id: amitava_iitm@yahoo.com

    thanx for help

  8. #8
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819

    Arrow

    Quote Originally Posted by tava.amitava
    Can you tell me which one will be best option for me. if i do it in excell there will be lots of files. so i think acces will be better( as said by access tutorials). where should i keep the access file? and what to do with it?
    waiting for reply.
    u can make it in access ?
    if so send us a simple table to understand it better .
    only the rest is a proper database connection and the SQL string that we will form it for u after seeing the tabel .
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  9. #9
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819

    Arrow

    Quote Originally Posted by tava.amitava
    you can mail me the procedure( it must be big) in my email id: amitava_iitm@yahoo.com

    thanx for help
    it's better to share answers for everybody here right ?
    I don't mind to contact u but only to have the benefit for everybody .
    moreover if u send us the tabel as I told u we will give u good answers here .
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  10. #10
    Join Date
    Dec 2006
    Posts
    49
    hi for the problem i have explained above I got a different method to solve that.
    as i said i have different curve for a specific Gh and Cp value. So i have made a notepad file which contains two columns one for Fn and one for Cp. What I need is make this type of multiple text file for each combination of Gh_Cp.

    whan I get the value of Gh and Cp from previous calculations I need to make a file name as : Gh_Cp.txt ( for ex. if gh=4 and Cp=0.8 the file name should be 4_0.8.txt

    now using open filename for input as #1 i can access the values inside the text file.

    this solves my problem.

    but now the new problem is to create the file name (Gh_Cp.txt)
    i have used this code to make the file name but it inserts a space in between i dont know why.

    Dim Fname, Gh, Cp, Fn As String
    Dim Gh1, Cp1, Fn1 As Double
    Dim i As Integer
    i = 0
    Gh1 = 4 ' lets say this are the values comes from calculation
    Cp1 = 8 ' lets say this are the values comes from calculation
    Fn1 = 3 ' lets say this are the values comes from calculation
    Gh = Str(Gh1)
    Cp = Str(Cp1)
    Fn = Str(Fn1)

    Fname = App.Path & "\data\" & Gh & "_" & Cp & ".txt"

    can any one help me to create a file name from numbers and please comment on the procedure i found.
    thanx.

  11. #11
    Join Date
    Dec 2006
    Posts
    49
    well I have removed the unnecessary space created by str() function using LTrim$(str(Gh)) etc.

    now can any on tell me what the exact code i need to use for reading the columns of the text file.

  12. #12
    Join Date
    Dec 2006
    Posts
    49
    one more doubt please

    in nearly every software we see there are previous/next buttons to go to the previous or next page of the software. how to do this.

    is it using

    form2.show
    me.hide

    please answer as soon as possible.

  13. #13
    Join Date
    Aug 2004
    Location
    Orange, California
    Posts
    1,263
    For one thing if you don't provide a data type for your variables then VB defaults to type Variant. So Fname, Gh, Cp, Gh1, and Cp1 are all variants not strings or doubles.
    If you use the CStr function in stead of the Str function you won't get the leading space. Here is the revised code:
    Code:
      Dim Fname As String, Gh As String, Cp As String, Fn As String
      Dim Gh1 As Double, Cp1 As Double, Fn1 As Double
      Dim i As Integer
      i = 0
      Gh1 = 4 ' lets say this are the values comes from calculation
      Cp1 = 8 ' lets say this are the values comes from calculation
      Fn1 = 3 ' lets say this are the values comes from calculation
      Gh = CStr(Gh1)
      Cp = CStr(Cp1)
      Fn = CStr(Fn1)
      
      Fname = App.Path & "\data\" & Gh & "_" & Cp & ".txt"
    Also as far a reading two columns it depends on how you seperated your coulumns. Are they serprated by a comma, or a tab character, or a space? Whatever you used you need to find the location of the seperator character and then split the string apart from there. For example if you used a comma then this should work:
    Code:
    Dim Buf As String
    Dim Col1 As Double
    Dim Col2 As Double
    Dim p As Long
    
    Open Fname For Input As #1
    
    Do While Not EOF(1)
      Line Input #1, Buf
      p=InStr(Buf, ",")
      Col1 = CDbl(Left(Buf, p-1))
      Col2 = CDbl(Right(Buf, Len(Buf)-p)
      Debug.Print Col1, Col2
    Loop
    
    Close #1
    Last edited by Ron Weller; 12-27-2006 at 01:57 PM.

  14. #14
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    Yea as Ron told u in vb not like c++ and any other langs ..

    dim a,b as byte '>>> b only is byte
    'to check that :
    b = 300 'error
    a = 300 'OK


    about the sequential shows like in wizards forms , u may put many "frame" control and in the same form make :

    frame1.hide
    frame2.show

    and will be better if u use array of frames :

    frame(i-1).hide
    frame(i).show
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  15. #15
    Join Date
    Dec 2006
    Posts
    49
    can u explain what is the use of p-1 and Len(Buf)-p.

    By the way thank you very much for the code. That works fine and I have done the coding for my application using your code.

    One problem i am facing now is i am digitizing a curve from a scanned page and the software i am using exports the x axis and y axis values as two columns in .csv file.

    I am coping the values of two columns and pasted them in a text file. Can you tell me what is the separator used in csv files. becoz otherwise i have to delete all the gaps between the two values in a row and type a space between them. I think they are separated by a Tab but what should I type instead of "," in

    p=InStr(Buf,",")

    and can you tell me how to clear debug window?

    thanx a lot

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center