Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Equivalent to the SQL code is?

Equivalent to the SQL code is?

Scheduled Pinned Locked Moved Visual Basic
databasehelpquestioncareer
11 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Milad Biroonvand

    hi Equivalent to the SQL code is? Public Class Form1 Public prgstr As String = Application.StartupPath Dim db As New ADODB.Connection Dim rs As New ADODB.Recordset Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load db.Provider = "Microsoft.Jet.OLEDB.4.0" db.Open("db.mdb") LoadTV() End Sub Private Sub LoadTV() 'On Error Resume Next rs.Open("[Folder]", db, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic) Dim K, I, J, L As Integer Dim T, R, Pr As String rs.MoveFirst() For I = 1 To rs.RecordCount K = rs.Fields("Level").Value If J < K Then J = K If Not rs.EOF Then rs.MoveNext() Next rs.MoveFirst() For I = 0 To J rs.MoveFirst() For L = 1 To rs.RecordCount K = rs.Fields("Level").Value T = rs.Fields("head").Value '*** TEXT R = rs.Fields("ID").Value '*** key = F+id Pr = rs.Fields("Parent").Value If I = 0 And K = 0 Then ' TV.Nodes.Add("F" & R, T, "bc", "bo") TV.Nodes.Add(R, T, "bc", "bo") Else If K = I Then ' TV.Nodes.Find("F" & Pr, True)(0).Nodes.Add("F" & R, T, "gc", "go") TV.Nodes.Find(Pr, True)(0).Nodes.Add(R, T, "gc", "go") End If End If My.Application.DoEvents() If Not rs.EOF Then rs.MoveNext() Next ' If Not rs.EOF Then rs.MoveNext() Next rs.Close() 'rs.Open("Matn", db) 'rs.MoveFirst() 'For I = 1 To rs.RecordCount ' K = rs.Fields("Folder").Value ' R = rs.Fields("ID").Value ' T = rs.Fields("Head").Value ' TV.Nodes.Find("F" & K, True)(0).Nodes.Add("M" & R, T, "mc", "mo") ' If Not rs.EOF Then rs.MoveNext() 'Next 'rs.Close() End Sub Sub CloseDB() rs.Close() db.Close() End Sub Private Sub TV_ItemDrag(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemDragEventArgs) Handles TV.ItemDrag DoDragDrop(e.Item, DragDropEffects.Move) End Sub Private Sub CreateRoot(ByVal Parrent As Integer, B

    A Offline
    A Offline
    Ashfield
    wrote on last edited by
    #2

    miladbiranvand wrote:

    Equivalent to the SQL code is?

    What SQL? What is the problem? Please be more specific, what is the error message? Where is it happening (run in debug to find out values).

    Bob Ashfield Consultants Ltd Proud to be a 2009 Code Project MVP

    1 Reply Last reply
    0
    • M Milad Biroonvand

      hi Equivalent to the SQL code is? Public Class Form1 Public prgstr As String = Application.StartupPath Dim db As New ADODB.Connection Dim rs As New ADODB.Recordset Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load db.Provider = "Microsoft.Jet.OLEDB.4.0" db.Open("db.mdb") LoadTV() End Sub Private Sub LoadTV() 'On Error Resume Next rs.Open("[Folder]", db, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic) Dim K, I, J, L As Integer Dim T, R, Pr As String rs.MoveFirst() For I = 1 To rs.RecordCount K = rs.Fields("Level").Value If J < K Then J = K If Not rs.EOF Then rs.MoveNext() Next rs.MoveFirst() For I = 0 To J rs.MoveFirst() For L = 1 To rs.RecordCount K = rs.Fields("Level").Value T = rs.Fields("head").Value '*** TEXT R = rs.Fields("ID").Value '*** key = F+id Pr = rs.Fields("Parent").Value If I = 0 And K = 0 Then ' TV.Nodes.Add("F" & R, T, "bc", "bo") TV.Nodes.Add(R, T, "bc", "bo") Else If K = I Then ' TV.Nodes.Find("F" & Pr, True)(0).Nodes.Add("F" & R, T, "gc", "go") TV.Nodes.Find(Pr, True)(0).Nodes.Add(R, T, "gc", "go") End If End If My.Application.DoEvents() If Not rs.EOF Then rs.MoveNext() Next ' If Not rs.EOF Then rs.MoveNext() Next rs.Close() 'rs.Open("Matn", db) 'rs.MoveFirst() 'For I = 1 To rs.RecordCount ' K = rs.Fields("Folder").Value ' R = rs.Fields("ID").Value ' T = rs.Fields("Head").Value ' TV.Nodes.Find("F" & K, True)(0).Nodes.Add("M" & R, T, "mc", "mo") ' If Not rs.EOF Then rs.MoveNext() 'Next 'rs.Close() End Sub Sub CloseDB() rs.Close() db.Close() End Sub Private Sub TV_ItemDrag(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemDragEventArgs) Handles TV.ItemDrag DoDragDrop(e.Item, DragDropEffects.Move) End Sub Private Sub CreateRoot(ByVal Parrent As Integer, B

      D Offline
      D Offline
      DaveAuld
      wrote on last edited by
      #3

      :omg: I put the first 1 vote in, and the reason is simple; You didn't take the hint when you posted your messages over the weekend, or listen to the comments I fed back to you then. Here you are again, Monday morning and posting this cr@p. You seriously need to FIFO. before you ask it stands for Fit In or F*** Off. Chris put these stickies at the top of the forum for a reason. You indicated you read them in one of your comments, but clearly you haven't. Your post is just asking for someone to do your work for you. WISE UP! Nobody is going to help you at this rate. DO YOU UNDERSTAND?

      Dave Who am I?: Web|Facebook|Twitter|LinkedIn|Bebo

      1 Reply Last reply
      0
      • M Milad Biroonvand

        hi Equivalent to the SQL code is? Public Class Form1 Public prgstr As String = Application.StartupPath Dim db As New ADODB.Connection Dim rs As New ADODB.Recordset Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load db.Provider = "Microsoft.Jet.OLEDB.4.0" db.Open("db.mdb") LoadTV() End Sub Private Sub LoadTV() 'On Error Resume Next rs.Open("[Folder]", db, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic) Dim K, I, J, L As Integer Dim T, R, Pr As String rs.MoveFirst() For I = 1 To rs.RecordCount K = rs.Fields("Level").Value If J < K Then J = K If Not rs.EOF Then rs.MoveNext() Next rs.MoveFirst() For I = 0 To J rs.MoveFirst() For L = 1 To rs.RecordCount K = rs.Fields("Level").Value T = rs.Fields("head").Value '*** TEXT R = rs.Fields("ID").Value '*** key = F+id Pr = rs.Fields("Parent").Value If I = 0 And K = 0 Then ' TV.Nodes.Add("F" & R, T, "bc", "bo") TV.Nodes.Add(R, T, "bc", "bo") Else If K = I Then ' TV.Nodes.Find("F" & Pr, True)(0).Nodes.Add("F" & R, T, "gc", "go") TV.Nodes.Find(Pr, True)(0).Nodes.Add(R, T, "gc", "go") End If End If My.Application.DoEvents() If Not rs.EOF Then rs.MoveNext() Next ' If Not rs.EOF Then rs.MoveNext() Next rs.Close() 'rs.Open("Matn", db) 'rs.MoveFirst() 'For I = 1 To rs.RecordCount ' K = rs.Fields("Folder").Value ' R = rs.Fields("ID").Value ' T = rs.Fields("Head").Value ' TV.Nodes.Find("F" & K, True)(0).Nodes.Add("M" & R, T, "mc", "mo") ' If Not rs.EOF Then rs.MoveNext() 'Next 'rs.Close() End Sub Sub CloseDB() rs.Close() db.Close() End Sub Private Sub TV_ItemDrag(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemDragEventArgs) Handles TV.ItemDrag DoDragDrop(e.Item, DragDropEffects.Move) End Sub Private Sub CreateRoot(ByVal Parrent As Integer, B

        H Offline
        H Offline
        Henry Minute
        wrote on last edited by
        #4

        Several people have marked your post as a bad question without being brave enough to tell you why. Well so have I and here's why. 1) It is in no way clear what it is that you want. 2) You have surrounded your code with <code></code> tags. You should have used <pre></pre> tags, as they will retain formatting when you paste code between them, or allow you to put in formatting (indentation etc) on previously pasted code. If you used the 'inline code' widget (above the Text: box) then use the 'code block' one instead.

        Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

        M 1 Reply Last reply
        0
        • H Henry Minute

          Several people have marked your post as a bad question without being brave enough to tell you why. Well so have I and here's why. 1) It is in no way clear what it is that you want. 2) You have surrounded your code with <code></code> tags. You should have used <pre></pre> tags, as they will retain formatting when you paste code between them, or allow you to put in formatting (indentation etc) on previously pasted code. If you used the 'inline code' widget (above the Text: box) then use the 'code block' one instead.

          Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

          M Offline
          M Offline
          Milad Biroonvand
          wrote on last edited by
          #5

          im sorry. example in Access dim da as new oledbdataadabtor in sql dim da as new sqldataadabtor now in Access Dim db As New ADODB.Connection Dim rs As New ADODB.Recordset in sql = ???? ----- and db.Provider = "Microsoft.Jet.OLEDB.4.0" db.Open("db.mdb") in sql = ???? in Access =

          Private Sub LoadTV()
          'On Error Resume Next
          rs.Open("[Folder]", db, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic)
          Dim K, I, J, L As Integer
          Dim T, R, Pr As String
          rs.MoveFirst()
          For I = 1 To rs.RecordCount
          K = rs.Fields("Level").Value
          If J < K Then J = K
          If Not rs.EOF Then rs.MoveNext()
          Next
          rs.MoveFirst()
          For I = 0 To J
          rs.MoveFirst()
          For L = 1 To rs.RecordCount
          K = rs.Fields("Level").Value
          T = rs.Fields("head").Value '*** TEXT
          R = rs.Fields("ID").Value '*** key = F+id
          Pr = rs.Fields("Parent").Value

                      If I = 0 And K = 0 Then
                          ' TV.Nodes.Add("F" & R, T, "bc", "bo")
                          TV.Nodes.Add(R, T, "bc", "bo")
                      Else
                          If K = I Then
                              '    TV.Nodes.Find("F" & Pr, True)(0).Nodes.Add("F" & R, T, "gc", "go")
                              TV.Nodes.Find(Pr, True)(0).Nodes.Add(R, T, "gc", "go")
                          End If
                      End If
          
                      My.Application.DoEvents()
                      If Not rs.EOF Then rs.MoveNext()
          
                  Next
                  '          If Not rs.EOF Then rs.MoveNext()
          
              Next
              rs.Close()
              'rs.Open("Matn", db)
              'rs.MoveFirst()
              'For I = 1 To rs.RecordCount
              '    K = rs.Fields("Folder").Value
              '    R = rs.Fields("ID").Value
              '    T = rs.Fields("Head").Value
              '    TV.Nodes.Find("F" & K, True)(0).Nodes.Add("M" & R, T, "mc", "mo")
              '    If Not rs.EOF Then rs.MoveNext()
              'Next
          
              'rs.Close()
          
          
          End Sub
          

          in sql =??? Do you UNDERSTAND?

          D H 2 Replies Last reply
          0
          • M Milad Biroonvand

            im sorry. example in Access dim da as new oledbdataadabtor in sql dim da as new sqldataadabtor now in Access Dim db As New ADODB.Connection Dim rs As New ADODB.Recordset in sql = ???? ----- and db.Provider = "Microsoft.Jet.OLEDB.4.0" db.Open("db.mdb") in sql = ???? in Access =

            Private Sub LoadTV()
            'On Error Resume Next
            rs.Open("[Folder]", db, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic)
            Dim K, I, J, L As Integer
            Dim T, R, Pr As String
            rs.MoveFirst()
            For I = 1 To rs.RecordCount
            K = rs.Fields("Level").Value
            If J < K Then J = K
            If Not rs.EOF Then rs.MoveNext()
            Next
            rs.MoveFirst()
            For I = 0 To J
            rs.MoveFirst()
            For L = 1 To rs.RecordCount
            K = rs.Fields("Level").Value
            T = rs.Fields("head").Value '*** TEXT
            R = rs.Fields("ID").Value '*** key = F+id
            Pr = rs.Fields("Parent").Value

                        If I = 0 And K = 0 Then
                            ' TV.Nodes.Add("F" & R, T, "bc", "bo")
                            TV.Nodes.Add(R, T, "bc", "bo")
                        Else
                            If K = I Then
                                '    TV.Nodes.Find("F" & Pr, True)(0).Nodes.Add("F" & R, T, "gc", "go")
                                TV.Nodes.Find(Pr, True)(0).Nodes.Add(R, T, "gc", "go")
                            End If
                        End If
            
                        My.Application.DoEvents()
                        If Not rs.EOF Then rs.MoveNext()
            
                    Next
                    '          If Not rs.EOF Then rs.MoveNext()
            
                Next
                rs.Close()
                'rs.Open("Matn", db)
                'rs.MoveFirst()
                'For I = 1 To rs.RecordCount
                '    K = rs.Fields("Folder").Value
                '    R = rs.Fields("ID").Value
                '    T = rs.Fields("Head").Value
                '    TV.Nodes.Find("F" & K, True)(0).Nodes.Add("M" & R, T, "mc", "mo")
                '    If Not rs.EOF Then rs.MoveNext()
                'Next
            
                'rs.Close()
            
            
            End Sub
            

            in sql =??? Do you UNDERSTAND?

            D Offline
            D Offline
            DaveAuld
            wrote on last edited by
            #6

            You still haven't come up with a specific problem you just want someone to rewrite the code to to use an SQL data provider instead of a JET provider. I suggest that you break down your code into its functional blocks, and go read the documentation relating to System.Data namespace and the classes within, such as the SQLConnection, SQLCommand, SQLDataAdapter, SQLDataReader etc.

            Dave Who am I?: Web|Facebook|Twitter|LinkedIn|Bebo

            M 1 Reply Last reply
            0
            • D DaveAuld

              You still haven't come up with a specific problem you just want someone to rewrite the code to to use an SQL data provider instead of a JET provider. I suggest that you break down your code into its functional blocks, and go read the documentation relating to System.Data namespace and the classes within, such as the SQLConnection, SQLCommand, SQLDataAdapter, SQLDataReader etc.

              Dave Who am I?: Web|Facebook|Twitter|LinkedIn|Bebo

              M Offline
              M Offline
              Milad Biroonvand
              wrote on last edited by
              #7

              Does anyone with a friend ? Me into your code by . thank you.

              S 1 Reply Last reply
              0
              • M Milad Biroonvand

                im sorry. example in Access dim da as new oledbdataadabtor in sql dim da as new sqldataadabtor now in Access Dim db As New ADODB.Connection Dim rs As New ADODB.Recordset in sql = ???? ----- and db.Provider = "Microsoft.Jet.OLEDB.4.0" db.Open("db.mdb") in sql = ???? in Access =

                Private Sub LoadTV()
                'On Error Resume Next
                rs.Open("[Folder]", db, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic)
                Dim K, I, J, L As Integer
                Dim T, R, Pr As String
                rs.MoveFirst()
                For I = 1 To rs.RecordCount
                K = rs.Fields("Level").Value
                If J < K Then J = K
                If Not rs.EOF Then rs.MoveNext()
                Next
                rs.MoveFirst()
                For I = 0 To J
                rs.MoveFirst()
                For L = 1 To rs.RecordCount
                K = rs.Fields("Level").Value
                T = rs.Fields("head").Value '*** TEXT
                R = rs.Fields("ID").Value '*** key = F+id
                Pr = rs.Fields("Parent").Value

                            If I = 0 And K = 0 Then
                                ' TV.Nodes.Add("F" & R, T, "bc", "bo")
                                TV.Nodes.Add(R, T, "bc", "bo")
                            Else
                                If K = I Then
                                    '    TV.Nodes.Find("F" & Pr, True)(0).Nodes.Add("F" & R, T, "gc", "go")
                                    TV.Nodes.Find(Pr, True)(0).Nodes.Add(R, T, "gc", "go")
                                End If
                            End If
                
                            My.Application.DoEvents()
                            If Not rs.EOF Then rs.MoveNext()
                
                        Next
                        '          If Not rs.EOF Then rs.MoveNext()
                
                    Next
                    rs.Close()
                    'rs.Open("Matn", db)
                    'rs.MoveFirst()
                    'For I = 1 To rs.RecordCount
                    '    K = rs.Fields("Folder").Value
                    '    R = rs.Fields("ID").Value
                    '    T = rs.Fields("Head").Value
                    '    TV.Nodes.Find("F" & K, True)(0).Nodes.Add("M" & R, T, "mc", "mo")
                    '    If Not rs.EOF Then rs.MoveNext()
                    'Next
                
                    'rs.Close()
                
                
                End Sub
                

                in sql =??? Do you UNDERSTAND?

                H Offline
                H Offline
                Henry Minute
                wrote on last edited by
                #8

                Take a look at this[^]. It is a tutorial on the process of converting ADO to ADO.Net. Give it a try, and come back with specific questions about anything you cannot get to work. Good Luck! :)

                Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

                M 1 Reply Last reply
                0
                • M Milad Biroonvand

                  Does anyone with a friend ? Me into your code by . thank you.

                  S Offline
                  S Offline
                  Steven J Jowett
                  wrote on last edited by
                  #9

                  miladbiranvand wrote:

                  Does anyone with a friend ? Me into your code by . thank you

                  What? That's jibberish.

                  Steve Jowett ------------------------- Real programmers don't comment their code. If it was hard to write, it should be hard to read.

                  1 Reply Last reply
                  0
                  • H Henry Minute

                    Take a look at this[^]. It is a tutorial on the process of converting ADO to ADO.Net. Give it a try, and come back with specific questions about anything you cannot get to work. Good Luck! :)

                    Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

                    M Offline
                    M Offline
                    Milad Biroonvand
                    wrote on last edited by
                    #10

                    You say solution .

                    M 1 Reply Last reply
                    0
                    • M Milad Biroonvand

                      You say solution .

                      M Offline
                      M Offline
                      Milad Biroonvand
                      wrote on last edited by
                      #11

                      code is

                      Public Class Form1
                      Public DsCenter As New DataSet
                      Public Count As Integer = 1

                      Private Sub Form1\_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
                          FillDsCenter()
                          LoadTV()
                      End Sub
                      
                      Public Sub FillDsCenter()
                          Dim StrSql As String
                          Dim da As New OleDbDataAdapter
                          If Con.State = ConnectionState.Closed Then
                              Con.Open()
                          End If
                          StrSql = "SELECT  \*  FROM Folder"
                          da = New OleDbDataAdapter(StrSql, Con)
                          DsCenter.Clear()
                          da.Fill(DsCenter, "tbl")
                          Con.Close()
                      End Sub
                      
                      
                      Private Sub LoadTV()
                      
                          Dim K, I, J, L As Integer '1
                          Dim T, R, Pr As String '2
                          Count = 1 '3 
                          For I = 1 To DsCenter.Tables("tbl").Rows.Count '4
                              K = DsCenter.Tables("tbl").Rows(Count - 1).Item("Level") '5
                              If J < K Then J = K '6
                              If Not (Count = DsCenter.Tables("tbl").Rows.Count) Then Count += 1
                          Next 'ok
                          Count = 1 'ok 
                          For I = 0 To J 'ok
                              Count = 1 'ok
                              For L = 1 To DsCenter.Tables("tbl").Rows.Count 'ok
                                  K = DsCenter.Tables("tbl").Rows(Count - 1).Item("Level") 'ok
                                  T = DsCenter.Tables("tbl").Rows(Count - 1).Item("head") 'ok
                                  R = DsCenter.Tables("tbl").Rows(Count - 1).Item("ID") 'ok
                                  Pr = DsCenter.Tables("tbl").Rows(Count - 1).Item("Parent") 'ok
                      
                                  If I = 0 And K = 0 Then 'ok
                                      TV.Nodes.Add(R, T, "bc", "bo") 'ok
                                  Else 'ok
                                      If K = I Then 'ok
                      
                                          TV.Nodes.Find(Pr, True)(0).Nodes.Add(R, T, "gc", "go") 'ok
                                      End If 'ok
                                  End If 'ok
                      
                                  If Count <> DsCenter.Tables("tbl").Rows.Count Then Count += 1
                              Next
                          Next
                      
                      
                          '\*\*\* table matn
                          'Count = 1
                          'For I = 1 To DsCenter.Tables("tbl").Rows.Count
                          '    K = DsCenter.Tables("tbl").Rows(Count - 1).Item("Folder")
                          '    R = DsCenter.Tables("tbl").Rows(Count - 1).Item("ID")
                          '    T = DsCenter.Tables("tbl").Rows(Count - 1).Item("Head")
                          '    TV.Nodes.Find("F" & K, True)(0).Nodes.Add("M" & R, T, "mc", "mo")
                          '    If Count <> DsCenter.Tables("tbl").Rows.Count Then Count += 1
                          'Next
                      End Sub
                      
                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups