1

Background

I am writing my first c# application, and would like to display the results of an SQL query in my application.

I would like the query to run against the database on a button click event. The results are to be displayed as read only and I would like them to be displayed in a table, not text boxes.

Form

What I have managed to create so far by drag and dropping from the 'ToolBar' in Visual Studio 2014.

Gui

SQL query

select * from station

This isn't my exact query but it doesn't differ much as is still a select statement.

What I have done so far

  • Connected a dataset which includes the table I want to run the query on.
  • Added datagridview
  • Added button

Question

Could some one point me in the right direction? I don't necessarily want someone to write the code just advise what the next step is.

What do I do next?

My guess

I create some kind of event on button click that runs the query and brings back the records in the datagridview?

I have no idea how to do the above is it is correct however.

Dan Cundy
  • 2,649
  • 2
  • 38
  • 65

1 Answers1

0

If you double click "button1" in visual studio it should create the event for you and take you to the code. Then you need to write the code that will execute when the button is clicked. Take a look at this question: Populate a datagridview with sql query results

Community
  • 1
  • 1