`
lanfei
  • 浏览: 150492 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

简单的 增删改查

    博客分类:
  • C#
 
阅读更多
 
try
    {
        String connectionString =
            "Integrated Security=SSPI;Persist Security Info=False;" +
            "Initial Catalog=Northwind;Data Source=localhost";
        dataAdapter = new SqlDataAdapter(selectCommand, connectionString);

        SqlCommandBuilder commandBuilder = new SqlCommandBuilder(dataAdapter);

        DataTable table = new DataTable();
        table.Locale = System.Globalization.CultureInfo.InvariantCulture;
        dataAdapter.Fill(table);
        bindingSource1.DataSource = table;

        dataGridView1.AutoResizeColumns( 
            DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
    }
    catch (SqlException)
    {
        MessageBox.Show("To run this example, replace the value of the " +
            "connectionString variable with a connection string that is " +
            "valid for your system.");
    }
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics