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:
Quote:
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!
Re: Execute query on OpenFileDialog chosen file?
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"