Reg: Where is My Output? after Pressing the run button

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sivadhanekula
    New Member
    • Nov 2008
    • 58

    Reg: Where is My Output? after Pressing the run button

    Hi everyone...

    I am using Visual basic 6.0 version...as I said in the previous thread I am very much new to Visual basic and poor knowledge in programming...I have done a small program in it to extract a particular data from the database of Mysql...In the program I have taken a OK button and in that I have written some lines of code to extract the data...I thought if I press OK button in the output I will get the list of the extracted data...but there is nothing displaying even after pressing the Ok button the screen stay's still...can you help me in this..This is the program
    Is it necessary to give some plug-ins if I am using database in Visual basic..if so how to give that?
    Option Explicit
    '>>>>>>>>>>>>>> >>>>>>>>>

    Const BUTTON1 = "&OK"

    '>>>>>>>>>>>>>> >>>>>>>>>

    Private Sub Okbutton_Click( )

    Dim sConnect As String
    Dim db As Database
    Dim rs As Recordset
    Dim doubleID As Double
    Dim doubleID1 As Double
    Dim intstring As String

    sConnect = "ODBC;DSN=WinUT MS_RT_DB;UID=Lo calhost;PWD=;Da tabase=WinUTMS_ RT_DB;"

    Set db = gwsMainWS.OpenD atabase("", 0, 0, sConnect)

    Set rs = db.OpenRecordse t("SELECT Messwert, UPLimWert FROM abssubtest where Messwert LIKE ")
    Do While Not rs.EOF
    doubleID = rs!Messwert
    doubleID1 = rs!UPLimWert
    intstring = rs.Fields(1)
    rs.MoveNext
    Loop
    End Sub
    Fast reply will be really helpfull for me

    Thanks and regards
    Siva
  • vdraceil
    New Member
    • Jul 2007
    • 236

    #2
    What you have done is just open a database,read it and store it in a variable(actual ly you are overwriting the variable in your do while loop)..you must have to use some sort of output actions/commands like msgbox or you can write your output in a text file etc..
    try writing..
    msgbox "doubleID: " & doubleID & vbnewline & "doubleID1: " & doubleID1 & vbnewline & "intstring: " & intstring
    inside your do while loop.

    Comment

    • debasisdas
      Recognized Expert Expert
      • Dec 2006
      • 8119

      #3
      you have done nothing to get any output on the screen in your code.

      Comment

      • sivadhanekula
        New Member
        • Nov 2008
        • 58

        #4
        I am getting a compile error

        "User-defined type not defined"
        and after pressing Ok, the cursor is going to "Dim db As Database" in the program....

        it may be because of the library files...can you tell me how to add the library files for the database....if not what might be the reason

        Comment

        • EYE4U
          Banned
          New Member
          • Oct 2008
          • 76

          #5
          Add Reference to Microsoft ADO Data 2.0.

          ARUZ

          Comment

          • sivadhanekula
            New Member
            • Nov 2008
            • 58

            #6
            Sorry I didn't get you...´can you explain in detail

            Comment

            • EYE4U
              Banned
              New Member
              • Oct 2008
              • 76

              #7
              Goto Project menu and select References. A Dialogue Box will appeared from that box you have to check Microsoft ADO Data 2.0 and then press OK.

              ARUZ

              Comment

              • sivadhanekula
                New Member
                • Nov 2008
                • 58

                #8
                Thank you...now the program is running!!!....

                Can you help me how to Take a FILE in between the program to save the extracted data into it so as it could be helpfull for the future, analysis task.


                Thank you

                Regards
                Siva

                Comment

                • EYE4U
                  Banned
                  New Member
                  • Oct 2008
                  • 76

                  #9
                  Sorry i didnt get you. DO you want to save data to a file from some database???

                  Comment

                  • sivadhanekula
                    New Member
                    • Nov 2008
                    • 58

                    #10
                    Private Sub Okbutton_Click( )
                    On Error Resume Next

                    Dim sConnect As String
                    Dim db As Database
                    Dim rs As Recordset
                    Dim Ws As Workspace
                    'Dim ID As Double
                    'Dim doubleID1 As Double
                    Dim intstring As String

                    Set Ws = DBEngine.Worksp aces(0)

                    sConnect = "ODBC;DSN=WinUT MS_RT_DB;UID=Lo calhost;PWD=;Da tabase=WinUTMS_ RT_DB;"

                    Set db = Ws.OpenDatabase ("", 0, 0, sConnect)

                    Set rs = db.OpenRecordse t("SELECT Modus FROM absprfg")
                    Do While Not rs.EOF
                    'ID = rs!Messwert
                    'doubleID1 = rs!UPLimWert
                    intstring = rs.Fields("Modu s")
                    rs.MoveNext
                    Loop
                    End Sub
                    ya..If I run the above program, there are no errors in it and I am able to extract the data from the database...now I have to save that extracted data in an excel sheet directly with the help of program... i.e. I have to take a file and write some program so that if I run the program the extracted data will be automatically saved to an excel sheet...hope you understand!...p lease can you help me in this...

                    Thank you for your support!

                    Comment

                    • EYE4U
                      Banned
                      New Member
                      • Oct 2008
                      • 76

                      #11
                      Ok i ll upload an example in which you can convert a mdb file into excel work sheet...

                      Comment

                      • sivadhanekula
                        New Member
                        • Nov 2008
                        • 58

                        #12
                        Ok...I'll wait for you...if possible make it fast ah.....thanq

                        Comment

                        • EYE4U
                          Banned
                          New Member
                          • Oct 2008
                          • 76

                          #13
                          I m sorry for replying late....

                          The attached application can convert mdb file into different formats....

                          Regards
                          ARUZ
                          Attached Files

                          Comment

                          • sivadhanekula
                            New Member
                            • Nov 2008
                            • 58

                            #14
                            thank you for the reply...may be you might have understand my question in wrong way or my english was poor..I dono...but I am not looking for the data conversion...al ready I have the data that is in the required format...which I dont need to convert...all I need is the extracted data should be saved to file that was specified by me...I have tried some thing if you look at the program....now I can take my extracted data to that particular file...but the problem is if the data is one line it is perfect and if I have lots of data there comes the problem....all data is storing in one row....but I want the data in different rows..I have used "\n" but getting some errors
                            Do While Not rs.EOF
                            'ID = rs!Messwert
                            'doubleID1 = rs!UPLimWert
                            intstring = rs.Fields(0)
                            rs.MoveNext

                            Open "K:\user\Dhanek ula\Visual Baisc\file.csv" For Random As #FreeFile
                            intMsg = MsgBox("File file.csv opened")
                            Print #1, intstring
                            intMsg = MsgBox("Writing a" & intstring & " to file.csv ")

                            Close #1
                            'intMsg = MsgBox("File file.csv closed")
                            Loop
                            If you look at the program...an excel sheet will be automatically added in the given path after I run the program..and the data will be printed to that with the print command...till that is Ok but later I have some problem's....

                            1. How to get the data in different rows if I have more than one testname(fields )
                            2. How to convert ',' to '.' (i.e. If I have a number 3,46 I need to convert it ti 3.46)

                            Please can you help me in this situation....
                            thank you for the example program given in the previous thread...it might help me for the other project

                            Comment

                            • EYE4U
                              Banned
                              New Member
                              • Oct 2008
                              • 76

                              #15
                              Use this code to replace , with .
                              Code:
                              msgbox Replce ("3,46",",",".")
                              Suppose you have following Fields in database table :
                              1. ID
                              2. Name
                              3. Address

                              Code:
                              msgbox (rs.Fields(0) & rs.Fields(1) & rs.Fields(2)
                              This code will get the id, name and address and show them in a message box.

                              If you need any example just ask for that.

                              Regards
                              ARUZ

                              Comment

                              Working...