Results 1 to 3 of 3

Thread: Execute query on OpenFileDialog chosen file?

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2014
    Posts
    4

    Execute query on OpenFileDialog chosen file?

    So, i need to finish this project soon, and I'm stuck, firstly i made everything workusing a sample file as a data source,
    I made a combobox show me the distinct values of a column, using an sql query. Problem is, the actual files the user will use will have different names every time. that's why i chose to use the openfiledialog.

    Now, how do i replace everything so it runs the query on any Access database that is chosen using the openfiledialog?

    Is it possible in the first place? or should I resort to telling the user to rename the file to the name of the Data Source, and moving it to the same folder every time?

    The code i have at the moment to run the query on the data source is simply copied from what a FillByToolSTripButton generates, FillBy being the name of that query. Its something like this:

    Try
    Me.MyTableAdapter.FillBy(Me.MyDataSet.MyTable)
    Catch ex As System.Exception
    System.Windows.Forms.MessageBox.Show(ex.Message)
    End Try
    That, along with the correct data source and display members for the combobox shows me exactly what I need.

    Please help, thanks guys!

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,458

    Re: Execute query on OpenFileDialog chosen file?

    you can bind your data through code:

    http://code.msdn.microsoft.com/DataBinding-91dfbcf4

  3. #3
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,181

    Re: Execute query on OpenFileDialog chosen file?

    If the databases will all have the same schema then you could just change the Tableadapters connectionstring. "Me.TableAdapter1.Connection.ConnectionString = newConnectionString"

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width