In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
How to display data in datagridview? Many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can gain something.
The first one is through property setting.
First find the DataSource property in the properties form and click the drop-down box. Use it for the first time, click to add data source every time you have joined
Select the data type, next, select the dataset, next
Select a data connection and click New connection.
In the add Link dialog box, change the data source (the SQL Server database I use) and click the drop-down box to select the server name (the dot defaults to your server). Then select the database at the connection to the data below, and click OK if the test link passes. Then go back to the data configuration wizard and click next to select the table you want to display in the database.
After joining, the execution window data is displayed.
Another way is to load data by writing code.
'define a function to find the amount charged within the specified date Public Function check_money (ByVal tstRecharge As Model.RechargeModel) As DataTable Dim strSQL As String = "select * from Recharge_info where rechargeDateTime between @ startdatetime and @ enddatetime" Dim params As SqlParameter () = {New SqlParameter ("@ startdatetime", tstRecharge.start_datetime), New SqlParameter ("@ enddatetime", tstRecharge.end_datetime)} Dim helper As New SqlHelper Dim dat = helper.GetDataTable (strSQL, CommandType.Text) Params) 'call sqlhelper Return dat' to return the found data table 'End Function Dim db As New DAL.CkeckMoneyDAL' to define a layer D object Used to call the D-layer function'to define a function Used to check the data returned by layer D lookup amount Public Function check_return (model As Model.RechargeModel) As DataTable Dim dat = db.check_money (model) If dat.Rows.Count = 0 Then 'check whether there is data in the data table returned by layer D' define a physical layer object Used to receive the start and end time thisRecharge.start_datetime = DateTimePicker1.Text thisRecharge.end_datetime = DateTimePicker2.Text Dim ub As New BLL.CheckMoneyBLL 'defines a layer B object that is used to call the layer B function If ub.check_return (thisRecharge) Is Nothing Then MsgBox ("there is no record in this time period, please set the time period again!" , MsgBoxStyle.Exclamation, vbOKOnly) Else dvwTitles.DataSource = ub.check_return (thisRecharge) 'pass the found data to datagridview End If
Display the results:
The two methods have their own advantages and disadvantages, and we need to choose to use them according to our own actual situation. When we only need to display the data in the entire table or when there is not much data in the table, the first method is the easiest way to do it, without having to write any code. Suppose we want the data to be displayed selectively. For example, the figure above only shows the data for the period from June 18 to June 20. Although writing code may seem tedious, the display result is clear at a glance. It avoids us from finding the data we need from a large amount of data, and greatly improves the efficiency.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.