int FindItemLength=FindItem.Length;
if(FindItemLength<1) return -1;
int FindTargetLength=FindTarget.Length;
if((FindTargetLength-1)<FindItemLength) return -1;
Dim strConn As String
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & strFile & ";" & "Extended Properties=Excel 8.0;"
Dim conn As OleDbConnection
Dim oda As OleDbDataAdapter
Dim commb As OleDbCommandBuilder
Dim dt As DataTable
Dim strSheetName As String '工作表的名称
Dim strComText As String 'sql语句
Dim Ds As DataSet '得到的数据集
conn = New OleDbConnection(strConn)
oda = New OleDbDataAdapter(strConn, conn)
conn.Open()
commb = New OleDbCommandBuilder(oda)
dt = conn.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, New Object() {Nothing, Nothing, Nothing, "TABLE"})
将dt邦定到DropDownlist,TextField,ValueField应该是"TABLE"中就可以了
剩下的就不用说了吧
'以上为得到Excel中工作表的名字,表的第二列表示工作表的名称
strComText = "SELECT * FROM [" & strSheetName & "]"