Vb.net database programming (04): a simple example of SQLserver modification records.

Source: Internet
Author: User
Similarly, the modification only returns the result to the database and does not display it. Therefore, the user is prompted with a judgment. The modification is successful or failed, so that the user can proceed to the next step. This example is simpler, because we reduce the code for the result of another query. The modification uses the non-query method in SQlcommand. Therefore, DataAdapter and D are not used.

Similarly, the modification only returns the result to the database and does not display it. Therefore, the user is prompted with a judgment. The modification is successful or failed, so that the user can proceed to the next step. This example is simpler, because we reduce the code for the result of another query. The modification uses the non-query method in SQlcommand. Therefore, DataAdapter and D are not used.

Similarly, the modification only returns the result to the database and does not display it.

Therefore, the user is prompted with a judgment. The modification is successful or failed, so that the user can proceed to the next step.


This example is simpler, because we reduce the code for the result of another query.


The modification uses the non-query method in SQlcommand. Therefore, DataAdapter and DataSet are not used.


Imports System. data. sqlClientPublic Class Form1 Dim cn As SqlConnection Dim cm As SqlCommand Private Sub button#click (sender As Object, e As EventArgs) Handles Button1.Click Try cn = New SqlConnection ("Data Source = 127.0.0.1; initial Catalog = Sales; Integrated Security = False; User ID = sa; Password = 123456; ") cn. open () 'cannot be less cm = New SqlCommand (TextBox1.Text, cn) cm. executeNonQuery () cn. close () MessageBox. show ("operation successful") Catch ex As Exception MessageBox. show ("operation failed") End Try End SubEnd Class

The result is as follows:



This example reduces the integration of ECHO and modifying SQL statements in the Code, so that you can see different implementations when performing modifications.


SQlcommand is different.

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.