(C#)excel數(shù)據(jù)導(dǎo)入SqlServer中本站整理 網(wǎng)絡(luò)搜集 2008-05-07 點(diǎn)擊: 我要評(píng)論excel|server|sqlserver|數(shù)據(jù)
或(實(shí)驗(yàn)題附件2)成績登記表.xls) 導(dǎo)入到SQL SERVER2000數(shù)據(jù)庫中. 要求: 1、EXCEL文件作為數(shù)據(jù)源 2、根據(jù)EXCEL文件的字段在SQL SERVER中建立對(duì)應(yīng)的字段 3、把EXECL中的記錄導(dǎo)到SQL SERVER中 string strCon = " Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = c:\\test.xls;Extended Properties=Excel 8.0" ; OleDbConnection myConn = new OleDbConnection (strCon) ; myConn.Open() ; string strCom = " Select Category,Comp_Num FROM [Sheet1$] " ; OleDbDataAdapter myCommand = new OleDbDataAdapter(strCom,myConn); dataSet1 = new DataSet(); myCommand.Fill (dataSet1 , "[Sheet1$]"); myConn.Close(); |
|