?
Solved

VB.net DataGridView run time Data Source

Posted on 2011-03-09
5
Medium Priority
?
1,058 Views
Last Modified: 2012-05-11
Normally I create a DataGridView by first creating a datasource using a table or tables or a view in SQL, then I drag and drop the data source onto the dgv control.

In this case, though, I need to see if it is possible to use one dgv control, but change the data source at run time.  The purpose of the dgv will be to display the results of a select query with a WHERE clause that uses a parameter for an order number.  The VB needs to launch the query and pass in the parameter.

I can do all of that, but multiple people at different workstations will be using the dgv at the same time and passing in different parameters, so I can't just populate the datasource table with the results of the query because of the need for simultaneous access.

Is there a way that I can just run the query at the workstation and use the results of the query as the datasource for the dgv on that computer?  Or, I can send the results of the query to a unique table name for each individual user, but I still need a way to change the datasource at each computer to identify the unique table.  Can this be done?

T
0
Comment
Question by:thoecherl
  • 2
  • 2
5 Comments
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 35085421
They will be using an individual installation of the application on each workstation ? yes?
The you don't need to do what you are suggesting as each application will make an individual call to the database with that users parameters.
or am I missing something here?
0
 

Author Comment

by:thoecherl
ID: 35085484
Yes, they will be using an individual installation of the app at each workstation.   But I don't know how to return the results of the query to the dgv.

My experience with using VB.net datagridviews thus far has  been to drag and drop the previously defined data source onto the dgv control and let Visual Studio create the connection. That now becomes permanent and for all of them I have done so far, the datasource is a table in SQL, not the result of an ad hoc query.

I realize this is probably pretty basic, but outside the realm of my current experience.
0
 
LVL 17

Expert Comment

by:nepaluz
ID: 35085623
you can using reflection.
there are some good tutorials on this but can not find them now. If I do, I will post, but here is one to start off

http://msdn.microsoft.com/en-us/magazine/cc163750.aspx
0
 
LVL 29

Accepted Solution

by:
Paul Jackson earned 2000 total points
ID: 35085727
Have a look here the example is in C# but you should easily be able to convert it to vb.net with an online convertor:
http://www.codeproject.com/KB/aspnet/DataGridView__GridView.aspx
0
 

Author Closing Comment

by:thoecherl
ID: 35100517
This worked perfectly.  Thank you
0

Featured Post

Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question