Writing the SqlHelper class example

Source: Internet
Author: User
Write your own sqlhelper, please refer to the use of it

Using system;using system.collections.generic;using system.linq;using system.text;using System.Windows;using System.windows.controls;using system.windows.data;using system.windows.documents;using System.Windows.Input;using System.windows.media;using system.windows.media.imaging;using system.windows.navigation;using System.windows.shapes;using System.Data;    Using System.data.sqlclient;namespace sqlhelper{///<summary>///Window1.xaml interactive logic///</summary>        Public partial class Window1:window {public Window1 () {InitializeComponent (); The SQL private void Btnds_click (object sender, RoutedEventArgs e) {sqlhelpe) is used only to execute query results less than            R.executenonqurey ("INSERT into t_student (name,age) VALUES (' Zhang San ',") ", new sqlparameter[0]);        MessageBox.Show ("add success"); private void Btndataset_click (object sender, RoutedEventArgs e) {DataSet ds= Sqlhelper.execute DataSet("SELECT * from t_student where hobbit= ' @hobbit '", New Sqlparameter[]{new SqlParameter ("' @hobbit '", "hahaha")})            ; foreach (DataRow row in DS. Tables[0].                Rows) {String name = (string) row["name"];            MessageBox.Show (name); }        }    }}

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.