首页 > 后端开发 > php教程 > 编写sqlhelper类示例

编写sqlhelper类示例

高洛峰
发布: 2023-03-04 19:56:02
原创
1436 人浏览过

自己编写SqlHelper,大家参考使用吧

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

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 的交互逻辑

    /// </summary>

    public partial class Window1 : Window

    {

        public Window1()

        {

            InitializeComponent();

        }

 

        //只用来执行查询结果比较少的sql

        private void btnds_Click(object sender, RoutedEventArgs e)

        {

            SqlHelper.ExecuteNonQurey("insert into T_Student(Name,Age) values(&#39;张三&#39;,55)",

                new SqlParameter[0]);

            MessageBox.Show("添加成功");

        }

 

        private void btnDataSet_Click(object sender, RoutedEventArgs e)

        {

            DataSet ds= SqlHelper.ExecuteDataSet("select * from T_Student where hobbit=&#39;@hobbit&#39;",

                new SqlParameter[]{new SqlParameter("&#39;@hobbit&#39;","哈哈哈")});

            foreach(DataRow row in ds.Tables[0].Rows)

            {

                string name = (string)row["Name"];

                MessageBox.Show(name);

            }

        }

    }

}

登录后复制

更多编写sqlhelper类示例相关文章请关注PHP中文网!

相关标签:
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板