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. populating a datagrid with the results of a SQL statement

populating a datagrid with the results of a SQL statement

Scheduled Pinned Locked Moved Visual Basic
questiondatabase
4 Posts 3 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 Offline
    M Offline
    mcm
    wrote on last edited by
    #1

    Dim strCompany As String strCompany = txtCompany.Text Dim findSQL As String findSQL = "Select * " & _ " from Client " & _ " Where name like '" & strCompany & " '%" the above is a SQL statement and i wish to populate a datagrid (either on the same page or a different one) with the results of the statement. How do i do this? Thank you!

    N H 2 Replies Last reply
    0
    • M mcm

      Dim strCompany As String strCompany = txtCompany.Text Dim findSQL As String findSQL = "Select * " & _ " from Client " & _ " Where name like '" & strCompany & " '%" the above is a SQL statement and i wish to populate a datagrid (either on the same page or a different one) with the results of the statement. How do i do this? Thank you!

      N Offline
      N Offline
      Nick Seng
      wrote on last edited by
      #2

      Is this question regarding VB6 or VB.net ? They way to populate the datagrid are quite different for for vb6 and .net Notorious SMC


      The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning Mark Twain
      Get your facts first, and then you can distort them as much as you please Mark Twain

      M 1 Reply Last reply
      0
      • M mcm

        Dim strCompany As String strCompany = txtCompany.Text Dim findSQL As String findSQL = "Select * " & _ " from Client " & _ " Where name like '" & strCompany & " '%" the above is a SQL statement and i wish to populate a datagrid (either on the same page or a different one) with the results of the statement. How do i do this? Thank you!

        H Offline
        H Offline
        Hesham Amin
        wrote on last edited by
        #3

        Iv'e wrote an article to answer a similar question.. her is the link: http://www.codeproject.com/useritems/DataBinding.asp

        1 Reply Last reply
        0
        • N Nick Seng

          Is this question regarding VB6 or VB.net ? They way to populate the datagrid are quite different for for vb6 and .net Notorious SMC


          The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning Mark Twain
          Get your facts first, and then you can distort them as much as you please Mark Twain

          M Offline
          M Offline
          mcm
          wrote on last edited by
          #4

          sorry for lack of detail,and thank you for your time! its vb6, as it stands my code is: Dim strCompany As String Dim strLikeCompany As String strCompany = txtCompany.Text strLikeCompany = strCompany & "*" Dim findSQL As String findSQL = " Select ClientCode, Company, ContactName " & _ " from Client " & _ " Where Company LIKE '" & strLikeCompany & "'" Set RS = Conn.Execute(findSQL) Adodc2.RecordSource = findSQL MsgBox ("Showing Results") Me.Adodc2.Refresh Me.DataGrid1.Refresh but it displays the error "no recordset specified, command text was not set for command object." on loading and it fails to populate grid.

          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