小编Dud*_*gav的帖子

什么是数据适配器的使用

任何人都可以解释为什么SqlDataAdapter在以下代码中使用?没有这个适配器,代码工作正常.

另外,我们为什么要使用DataAdapter?请帮我理解这个DataAdapter用法.

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                SqlConnection con = new SqlConnection("Data Source=.....\\SQLEXPRESS;Initial Catalog=......;Integrated Security=True");
                con.Open();

                SqlDataAdapter da =new SqlDataAdapter(); // Why use `SqlDataAdapter` here?
                SqlCommand sc = new SqlCommand("insert into bhargavc values(" + textBox1.Text + "," + textBox2.Text + ");", con);
                var o = sc.ExecuteNonQuery();
                MessageBox.Show(o + "record to be inserted");
                con.Close();
            }
            catch (Exception) …
Run Code Online (Sandbox Code Playgroud)

c# ado.net

2
推荐指数
2
解决办法
6938
查看次数

标签 统计

ado.net ×1

c# ×1