dcsimg
Results 1 to 10 of 10

Thread: DataBase load

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2015
    Posts
    71

    DataBase load

    Dim connection As New MySqlConnection("Server=;username=;password=")
    Dim table As New DataTable()
    Dim adapter As New MySqlDataAdapter("SELECT * FROM sql2256547.DataUsers", connection)

    adapter.Fill(table)

    DataGridView1.DataSource = table

    I have these code and it's working fine but i have problem that i don't want always to load datausers what i mean that i want to load what textbox.text say , please can someone help me

    Dim adapter As New MySqlDataAdapter("SELECT * FROM sql2256547.Textbox1.text", connection)

  2. #2
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,425

    Re: DataBase load

    Possibly:

    ("SELECT * FROM '" & sql2256547.Textbox1.text & "'", connection)

    Note the single quote, followed by a double quote and & , and then & followed by a double and a singhle then by a double quote.

    If that isn't what you wanted, then maybe using the WHERE clause to provided filtering.
    Handy References:
    MSDN Library
    ADO Tutorial Excel Tutorial MZTools (VB6)

    • Please pull down the Thread Tools menu and click the 'Mark Thread Resolved' button, or alternately edit your original post and add "Resolved" or place a in the subject when your question(s) have been answered.
    • Please use code tags [highlight=vb] your code goes here between the tags [/highlight] when posting code.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2015
    Posts
    71

    Re: DataBase load

    Name:  ffff.jpg
Views: 16
Size:  18.3 KB

  4. #4
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,425

    Re: DataBase load

    Well, what is "sql2256547" exactly?
    Last edited by Bruce Fox; Sep 15th, 2018 at 03:22 AM. Reason: Added "
    Handy References:
    MSDN Library
    ADO Tutorial Excel Tutorial MZTools (VB6)

    • Please pull down the Thread Tools menu and click the 'Mark Thread Resolved' button, or alternately edit your original post and add "Resolved" or place a in the subject when your question(s) have been answered.
    • Please use code tags [highlight=vb] your code goes here between the tags [/highlight] when posting code.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Mar 2015
    Posts
    71

    Re: DataBase load

    it's the database name where u can create tables

  6. #6
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,425

    Re: DataBase load

    Hi Yehya,

    So is the intent for the user to 'enter' the database name (via Textbox1.Text)? or just be able to 'filter' what records are pulled back?
    Handy References:
    MSDN Library
    ADO Tutorial Excel Tutorial MZTools (VB6)

    • Please pull down the Thread Tools menu and click the 'Mark Thread Resolved' button, or alternately edit your original post and add "Resolved" or place a in the subject when your question(s) have been answered.
    • Please use code tags [highlight=vb] your code goes here between the tags [/highlight] when posting code.

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Mar 2015
    Posts
    71

    Re: DataBase load

    hello sir

    i want to load the data that's on table to DataGridView and in sql2256547 there is a lot of table so i want to chose the table name as textbox.text to load the data on DataGridView

    Dim connection As New MySqlConnection("Server=;username=;password=")
    Dim table As New DataTable()
    Dim adapter As New MySqlDataAdapter("SELECT * FROM sql2256547.DataUsers", connection)

    adapter.Fill(table)

    DataGridView1.DataSource = table

    error here ("SELECT * FROM sql2256547.DataUsers", connection)

    i don't want always to load datausers i want to load that textbox.text is i hope you understand this is my project and i'm noob programming but i should do that
    Last edited by Yehya; Sep 15th, 2018 at 04:06 AM.

  8. #8
    Member
    Join Date
    Jul 2017
    Location
    Exeter, UK
    Posts
    58

    Re: DataBase load

    dim mycommand as string = "SELECT * FROM sql2256547." & textbox1.text
    Dim adapter As New MySqlDataAdapter(mycommand, connection)

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Mar 2015
    Posts
    71

    Re: DataBase load

    thanks you alot that helped me <3

  10. #10
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,425

    Re: DataBase load

    Something like:
    ("SELECT * FROM sql2256547. '" & Textbox1.text & "'", connection)
    Handy References:
    MSDN Library
    ADO Tutorial Excel Tutorial MZTools (VB6)

    • Please pull down the Thread Tools menu and click the 'Mark Thread Resolved' button, or alternately edit your original post and add "Resolved" or place a in the subject when your question(s) have been answered.
    • Please use code tags [highlight=vb] your code goes here between the tags [/highlight] when posting code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width