Страница: 1 | 2 |
|
Вопрос: Экспорт данных Excel-Access (с кодом, VB.net)
|
Добавлено: 19.05.10 17:34
|
|
Автор вопроса: Alba
|
Подскажите мне пожалуйста что я делаю не так и что я не доделываю для того чтобы процедура экспорта из Excel в Access (поячеечно) проходила должным образом.
Ответить
|
Номер ответа: 1 Автор ответа: Alba
Вопросов: 8 Ответов: 37
|
Профиль | | #1
|
Добавлено: 19.05.10 17:34
|
-
- Protected Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click
-
- Dim oExcel As Excel.Application
- Dim oCon As OleDbConnection
- Dim oCommand As OleDbCommand
- Dim oRS As ADODB.Recordset
-
- oExcel = New Excel.Application
- oCon = New OleDbConnection
- oCommand = New OleDbCommand
-
- Dim izv_id
- Dim izv_date
- Dim fil_name
- Dim o_name
- Dim ob_name
- Dim vozn_time
- Dim ystr_time
- Dim vozn_date
- Dim ystr_date
- Dim obor_type
- Dim obor_mark
- Dim proizv
- Dim zav_num
- Dim vip_date
- Dim vv_date
- Dim inv_num
- Dim yst_site
- Dim tempr
- Dim TO_date
- Dim prot_num
- Dim neisp_desc
- Dim ystr_met
- Dim posl
- Dim prich
- Dim povt_izv_date
- Dim predl_pov_nad
- Dim pril
- Dim pers
-
- oExcel.Visible = True
- Dim FileName As Boolean = True
- If IsPostBack = True And FileUpload1.HasFile = True Then
- Dim m_filePath As String = "C:\" & FileUpload1.FileName
- FileUpload1.PostedFile.SaveAs(m_filePath)
- oExcel.Workbooks.Open(m_filePath)
- End If
-
- izv_id = oExcel.Cells(2, 3)
- izv_date = oExcel.Cells(2, 5) & "." & oExcel.Cells(2, 6) & "." & oExcel.Cells(2, 7)
- fil_name = oExcel.Cells(6, 2)
- o_name = oExcel.Cells(8, 2)
- ob_name = oExcel.Cells(15, 2)
- vozn_time = oExcel.Cells(10, 4) & "." & oExcel.Cells(10, 5)
- ystr_time = oExcel.Cells(12, 4) & "." & oExcel.Cells(12, 5)
- vozn_date = oExcel.Cells(10, 7) & "." & oExcel.Cells(10, 8) & "." & oExcel.Cells(10, 9)
- ystr_date = oExcel.Cells(12, 7) & "." & oExcel.Cells(12, 8) & "." & oExcel.Cells(12, 9)
- obor_type = oExcel.Cells(17, 2)
- obor_mark = oExcel.Cells(19, 2)
- proizv = oExcel.Cells(21, 2)
- zav_num = oExcel.Cells(23, 2)
- vip_date = oExcel.Cells(23, 7) & "." & oExcel.Cells(23, 8) & "." & oExcel.Cells(23, 9)
- vv_date = oExcel.Cells(25, 2)
- inv_num = oExcel.Cells(27, 2)
- yst_site = oExcel.Cells(29, 2)
- tempr = oExcel.Cells(29, 7)
- TO_date = oExcel.Cells(31, 2)
- prot_num = oExcel.Cells(31, 6)
- neisp_desc = oExcel.Cells(33, 2)
- ystr_met = oExcel.Cells(35, 2)
- posl = oExcel.Cells(37, 2)
- prich = oExcel.Cells(39, 2)
- povt_izv_date = oExcel.Cells(41, 5) & "." & oExcel.Cells(41, 6) & "." & oExcel.Cells(41, 7)
- predl_pov_nad = oExcel.Cells(43, 3)
- pril = oExcel.Cells(45, 3)
- pers = oExcel.Cells(47, 2)
-
-
-
- oCon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\DB.mdb;Persist Security Info=False"
- oCon.Open()
-
-
- oCommand.CommandText = "insert into temp values ('" & izv_id & "','" & izv_date & "','" & fil_name & "','" & o_name & "','" & ob_name & "','" & vozn_time & "','" & ystr_time & "','" & vozn_date & "','" & ystr_date & "','" & obor_type & "','" & obor_mark & "','" & proizv & "','" & zav_num & "','" & vip_date & "','" & vv_date & "','" & inv_num & "','" & yst_site & "','" & tempr & "','" & TO_date & "','" & prot_num & "','" & neisp_desc & "','" & ystr_met & "','" & posl & "','" & prich & "','" & povt_izv_date & "','" & predl_pov_nad & "','" & pril & "','" & pers & "')"
-
- oCon = Nothing
- oCommand = Nothing
- ors = Nothing
- oExcel = Nothing
- End Sub
Ответить
|
Страница: 1 | 2 |
Поиск по форуму