using the table to display the data, is a very concise and clear function, the user can enter the conditions to choose to display their own needs of the part of the data, in the machine room reconstruction, I used the DataGridView control, a beautiful control.
The specific usage is as follows:
First, find the control, and in the "data", draw a DataGridView on the form that belongs to you.
There is a small arrow at the top right, click Select to add the project data source.
The following screen appears, directly click Next
To create a new connection, select data:
I'm here to use SQL Server:
Here you choose the name of your own server, along with your own database information:
To test the connection:
Select the database tables that you want to call.
The next step is to show that it may not be the title we want to show to the user, we need to set it up.
Click on the small triangle in the upper right corner and select Edit column to display the data we need.
If I want to query the conditional data, I want the card number of 2 recharge information, you need to "add a query":
Continue to click on the upper right corner of the small triangle, click Add Query, the box is the query we wrote, "@CardNo parameters" is our custom write, after, select query Builder.
This way, a query is added successfully and a single line of tools is found on the form:
In addition, there is automatically generated code in the form.
Specific code: Here you need to assign the contents of the TextBox box to tool tools, let us click the button to implement the tool function indirectly.
Public Class Form1 Private Sub form1_load (sender as Object, e as EventArgs) Handles mybase.load ' TODO: This line of code adds data Download to table "new. T_recharge "in. You can move or delete it as needed. Me.T_RechargeTableAdapter.Fill (Me. New. T_recharge) datagridview1.allowusertoaddrows = False ' Delete last line blank line query tools Trip. Hide () ' Hidden toolbar End sub Private Sub query Toolstripbutton_click (sender as Object, e as EventArgs) Handles query toolstripbut ton. Click ' assigns the textbox1 (user entered numeric value) to the added query Tooltextbox. Cardno parameter Toolstriptextbox.text = TextBox1.Text Try me.t_rechargetableadapter. Query (Me. New. T_recharge, Cardno Number Toolstriptextbox.text) Catch ex as System.Exception System.Windows.Forms.MessageBox.Show (ex. Message) End Try End Sub ' puts the tool's code in the BTN Query button's Click event under Private Sub Btnfind_click (sender as Object, E as Event Args) Handles Btnfind.click ' assigns textbox1 (the value entered by the user) to the added query Tooltextbox. Cardno parameter Toolstriptextbox.text = TextBox1.Text Try me.t_rechargetableAdapter. Query (Me. New. T_recharge, Cardno parameter toolstriptextbox.text) Catch ex as System.Exception system.windows. Forms.MessageBox.Show (ex. Message) End Try End SubEnd Class
Here is the final result diagram:
This is a use of DataGridView, which will generate a dataset, and another way is to directly assign a value to the DataGridView source, directly write code, so there is no more data set. Encounter new knowledge, new skills, do it, do it yourself, understand the deeper.
The use of "personal reconstruction of computer room" DataGridView