第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

未將對象引用設(shè)置到對象實例!錯誤在private void BindData()函數(shù)里!該怎么解決?

未將對象引用設(shè)置到對象實例!錯誤在private void BindData()函數(shù)里!該怎么解決?

紅糖糍粑 2021-10-13 15:11:21
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.OleDb;using System.Data.SqlClient;namespace ConnectionDB{public partial class Form2 : Form{DataSet ds;int recordCount;public Form2(){BuildData();BindData();recordCount = this.BindingContext[ds, "StudentInfo"].Count;}private void BuildData(){string constr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\\C#實驗\\ConnectionDB\\Database2.accdb";string str = "select * from [StudentInfo]";OleDbConnection conn = new OleDbConnection(constr);conn.Open();OleDbDataAdapter adapter = new OleDbDataAdapter(str, conn);OleDbCommandBuilder builder = new OleDbCommandBuilder(adapter);ds = new DataSet();adapter.Fill(ds, "StudentInfo");}private void BindData(){this.textBox1.DataBindings.Add(new Binding("Text", ds, "StudentInfo.SNo"));this.textBox2.DataBindings.Add(new Binding("Text", ds, "StudentInfo.Class"));this.textBox3.DataBindings.Add(new Binding("Text", ds, "StudentInfo.SName"));this.textBox4.DataBindings.Add(new Binding("Text", ds, "StudentInfo.Sgrade"));}private void Form2_Load(object sender, EventArgs e){}private void button2_Click(object sender, EventArgs e){}private void button1_Click(object sender, EventArgs e){this.BindingContext[ds, "StudentInfo"].Position -= 1;}private void button3_Click(object sender, EventArgs e){this.BindingContext[ds, "StudentInfo"].Position -= 1;}}}
查看完整描述

1 回答

?
慕標(biāo)琳琳

TA貢獻1830條經(jīng)驗 獲得超9個贊

private void BuildData()
{
string constr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\\C#實驗\\ConnectionDB\\Database2.accdb";
string str = "select * from [StudentInfo]";
OleDbConnection conn = new OleDbConnection(constr);
try
{
conn.Open();
OleDbDataAdapter adapter = new OleDbDataAdapter(str, conn);
OleDbCommandBuilder builder = new OleDbCommandBuilder(adapter);
ds = new DataSet();
adapter.Fill(ds, "StudentInfo");
}
catch (Exception)
{
throw;
}
}
看看輸出什么錯誤?



查看完整回答
反對 回復(fù) 2021-10-17
  • 1 回答
  • 0 關(guān)注
  • 201 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號