- ©«¤l
- 1
- ¥DÃD
- 1
- ºëµØ
- 0
- ¿n¤À
- 2
- ÂI¦W
- 0
- §@·~¨t²Î
- windows 7
- ³nÅ骩¥»
- Visual Studio 2015
- ¾\ŪÅv
- 10
- µù¥U®É¶¡
- 2016-5-10
- ³Ì«áµn¿ý
- 2016-5-10
|
[µo°Ý] ¶×¤JExcel¨ìDataGridView¦p¦ó³]©wUpdateCommand
³Ìªñ¾Ç¤F¤@Ó¥i¥H§âExcel¶×¤JDataGridViewªºµ{¦¡,¥i¬O²{¦b·Q§âDataGridView½s¿è«áªº¤º®e§Q¥ÎButton2ªºClick¨Æ¥ó¦A¶Ç¦^ExcelÀx¦s
¼gªºClick¨Æ¥óµ{¦¡½X¦p¤U:
private void button2_Click(object sender, EventArgs e)
{
string ExcelPath = System.Windows.Forms.Application.StartupPath + @"\testexcel.xls";
string OpenExcelData = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=" + ExcelPath + ";Extended Properties ='Excel 8.0;HDR=Yes;IMEX=2;ReadOnly=0'";
string OutputSheet = "Select * From [Sheet1$]";
OleDbConnection ExcelConnection = new OleDbConnection(OpenExcelData);
DataTable dTableOut = new DataTable();
DataSet dataset = new DataSet();
OleDbCommand ExCommendOut = new OleDbCommand(OutputSheet, ExcelConnection);
OleDbDataAdapter dataAdpter = new OleDbDataAdapter(ExCommendOut);
dataAdpter.Update(dTableOut);
}
¥i¬O°õ¦æ«áµo²{¨Ã¨S¦³Àx¦s¦¨¥\,°õ¦æ¸òÂIÀ»Button2®É³£¨Sµo¥Í°ÝÃD,¦ý´N¬O¨SÀx¦s§ó§ï¤º®e,
¤WºôGoogle¤@¤U,¦n¹³¬OExcelµLªk¥ÎdataAdpter.Update¨Ó°õ¦æ¦sÀÉ,n¨Ï¥Î"UpdateCommand"
¦³¥ý¸ÕµÛ·j´M¤@¤U,ÁÙ¬OµLªk¼g¥XUpdateCommandµ¹OleDbDataAdapter¥Î
¦³«e½ú¯àÀ°§U¤@¤U¶Ü?¯à¤£¯à¼gÓ¤p¤pªº½d¨Òµ¹¤p§Ì°Ñ¦Ò¤@¤U,·PÁ¦U¦ì«e½ú¤F |
|