Vb. NET Room charge & DataGridView Connection to database

Source: Internet
Author: User

Add Delete user, this is also related to the database table information Ah! In VB, we can easily call SQL statements with the control of the perfect combination, in vb.net of course there is a more humane way: directly using the control to connect to the database

Specific steps:

To connect to a data source:




Select the table or view or stored procedure that you want, and simply use the statement to display the data in the user table in the DataGridView Control.


You can modify the corresponding name:


This will show you the information you need, of course, you can edit the row, column, delete the information you do not need




so as soon as one runs, it will appear User table all the information, but this is not what we want, we need is the user level separation effect, we can add the query, gross position query hidden, of course, remember the query name and the corresponding query statement modified, you can click the Query Builder to see if the query is correct, Then click OK to do so.



The automatically generated code is as follows:

Private Sub Administrator Toolstripbutton_click (sender as Object, e as EventArgs) Handles Administrator Toolstripbutton.click        Try    ' Error statement, which executes the SQL statement me.t_usertableadapter about the administrator before writing            . Administrator (Me.UserChose.T_User)        Catch ex as System.Exception            System.Windows.Forms.MessageBox.Show (ex. Message)        End Try    End Sub

Knowledge Supplement: Perceptions of Bindingcource: Span class= "Selflink" >      bindingsource   Elements serve a variety of purposes.   First, it simplifies the By providing money management, change notifications and other services in Windows Forms controls and data sources   use   DataSource property, by attaching to the   of the data source; bindingsource   components to complete.

The above is their own initial understanding of it! For the database of learning really have to package onion-like, one layer of execution, because when the package to the last time will find that the original before each step of their own is the essence of the.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.