How do I read from an Excel file? How should the code be compared to the code of reading from Access?
Code:Protected Sub bindKomponenter() Dim strCn As String = "Provider=Microsoft.jet.oledb.4.0;" strCn += "Data Source=" & Server.MapPath("priser04.mdb") & ";" Dim cn As OleDbConnection = New OleDbConnection(strCn) Dim cmdText As String = "Select komponenter.Id as kompId, komponenter.Komponent FROM komponenter,materiale_komponenter WHERE materiale_komponenter.kompId=komponenter.id AND materiale_komponenter.MatId=" & intMatNr Dim cmd As OleDbCommand = New OleDbCommand(cmdText, cn) cmd.Connection.Open() komp1.DataSource = cmd.ExecuteReader() komp1.DataValueField = "kompId" komp1.DataTextField = "Komponent" komp1.DataBind() cmd.Connection.Close() cmd.Connection.Open() komp2.DataSource = cmd.ExecuteReader() komp2.DataValueField = "kompId" komp2.DataTextField = "Komponent" komp2.DataBind() cmd.Connection.Close() End Sub




Reply With Quote