首页上一页 1 下一页尾页 3 条记录 1/1页
实例Ex11_05
发表在C#图书答疑
2009-08-24
是否精华
是
否
版块置顶:
是
否
程序主代码如下:
private void button1_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "Server=DTISQF1EC5HJRRH\\SQL2005;uid=wangyongzhi;pwd=;database=db_11";
conn.Open();
DataTable dt = new DataTable("Resouce");
dt.Clear();
string SqlIns = "insert into tb_04 values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "')";
SqlCommand command = new SqlCommand(SqlIns, conn);
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = command;
adapter.Fill(dt);
dt.Clear();
SqlDataAdapter AdapterSelect = new SqlDataAdapter("select * from tb_04", conn);
AdapterSelect.Fill(dt);
dataGridView1.DataSource = dt.DefaultView;
}
问题:
1,DataTable dt = new DataTable("Resouce");这一行中()中的参数Resouce是从哪来的,是干什么用的?
2,adapter.Fill(dt);
dt.Clear();为什么刚填充完就要清除内存中的数据呢,这样填充实际的物理表了吗?哪句话体现填充实际的物理表?
3,string SqlIns = "insert into tb_04 values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "')";
括号里的参数怎么又是用单引号,又是用双引号,还有加号,这些符号具体在什么地方用
private void button1_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "Server=DTISQF1EC5HJRRH\\SQL2005;uid=wangyongzhi;pwd=;database=db_11";
conn.Open();
DataTable dt = new DataTable("Resouce");
dt.Clear();
string SqlIns = "insert into tb_04 values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "')";
SqlCommand command = new SqlCommand(SqlIns, conn);
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = command;
adapter.Fill(dt);
dt.Clear();
SqlDataAdapter AdapterSelect = new SqlDataAdapter("select * from tb_04", conn);
AdapterSelect.Fill(dt);
dataGridView1.DataSource = dt.DefaultView;
}
问题:
1,DataTable dt = new DataTable("Resouce");这一行中()中的参数Resouce是从哪来的,是干什么用的?
2,adapter.Fill(dt);
dt.Clear();为什么刚填充完就要清除内存中的数据呢,这样填充实际的物理表了吗?哪句话体现填充实际的物理表?
3,string SqlIns = "insert into tb_04 values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "')";
括号里的参数怎么又是用单引号,又是用双引号,还有加号,这些符号具体在什么地方用