c# dataSate 数据库问题

来源:百度知道 编辑:UC知道 时间:2024/05/25 07:48:18
c# DataSate 中 的疑难问题
新手新问!!!

private void button1_Click(object sender, EventArgs e)
{
//string s = "Proveider=Microsoft.Jet.OLEDB.4.0;Data source=d://student.mdb";
string s = " Provider= Microsoft.Jet.OLEDB.4.0 ; Data Source = d:\\student.mdb";
OleDbConnection conn = new OleDbConnection(s);
string sql="select * from stuBase ";
OleDbDataAdapter da = new OleDbDataAdapter(sql, conn);

DataSet temp = new DataSet();
da.Fill(temp, "stuBase");
DataRow rs = temp.Tables["stuBase"].NewRow(); //未将对象引用设置到对象的实例。?????

rs["stuid"] = textBox1.Text;
rs["stuname"] = textBox2.Text;
rs["stuage"] = textBox3.Text;

if (temp.HasChanges())
da.Update(temp

恭喜你了,遇到什么问题我们就好好研究研究吧

没有实力化对象,
DataRow rs =new DataRow();
rs = temp.Tables["stuBase"].NewRow();
这么写试试?

我头一开始练习时,也发生了这样的事情,你要自己建立UpdateCommand属性,接口可以根据自己的需要进行完善

da的UpdateCommand属性要自已创建

看看我的乱码:
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
//////Session["adm"] = TextBox1.Text;///////new add ???????
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
}

}
protected void Button1_Click(object sender, EventArgs e)
{
//////////////////////////////////////////////////输入判断
string strname,pwd1,pwd2,email;
strname = TextBox1.Text;
pwd1 = TextBox2.Text