Click here to Skip to main content
16,005,467 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Need simple help with oleDbDataAdapter exception Pin
sagmam2-Sep-04 19:41
sagmam2-Sep-04 19:41 
GeneralLike Statement Variables Pin
Dicescuz2-Sep-04 10:19
Dicescuz2-Sep-04 10:19 
GeneralRe: Like Statement Variables Pin
Dave Kreskowiak2-Sep-04 11:44
mveDave Kreskowiak2-Sep-04 11:44 
GeneralRe: Like Statement Variables Pin
Dicescuz2-Sep-04 18:04
Dicescuz2-Sep-04 18:04 
Generalvb.net Excel file to SQL table Pin
partt2-Sep-04 7:45
partt2-Sep-04 7:45 
GeneralRe: vb.net Excel file to SQL table Pin
Dave Kreskowiak2-Sep-04 9:35
mveDave Kreskowiak2-Sep-04 9:35 
GeneralRe: vb.net Excel file to SQL table Pin
partt2-Sep-04 9:58
partt2-Sep-04 9:58 
GeneralRe: vb.net Excel file to SQL table Pin
Purple Monk2-Sep-04 22:33
Purple Monk2-Sep-04 22:33 
Sorry i just read the title and its obvious that you are using vb.net but this should actually still work, i have it working in both, but this is a very cut down copy of what i've used as what i am doing is completely different

Not sure if this will help but if it is VB6 you are using it might so let me know, cheers

Private Sub Form_Load()
Dim oExcel As Object
Dim oWB As Object
Dim ows As Object
Dim oRS As New ADODB.Recordset
Dim i As Long
Dim newI As Long

'ammended
Dim oConn As New ADODB.Connection
oConn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=tempdb;Data Source=JETSTREAM"
oConn.Open

'Set yourself up a Table with all the fields required and fill a recordset
oRS.Open "SELECT * FROM TempTable", oConn, adOpenKeyset, adLockOptimistic

'Create yourself the excel application
Set oExcel = CreateObject("Excel.Application")
Set oWB = oExcel.Workbooks.Open(PathtoASpreadSheet)
Set ows = oWB.Worksheets("Sheet1")

'Loop through the first column until you hit the first blank cell
'This is a quick and dirty way there is probably a better way out there.

'ammended can't remember bloody overflow thing, also can't remember if i have the cells
'reference (i, A) round the right way.
For i = 1 To 65535

If ows.Cells(i, "A") = "" Then

newI = i

Exit For

End If

Next

'Then loop through every column and every cell adding the data to the recordset
'in the correct fields

For i = 1 To newI

'Can't remember if .value is required for the cells.
oRS.AddNew
oRS.Fields("FirstField").Value = ows.Cells(i, "A").Value
oRS.Fields("SecondField").Value = ows.Cells(i, "B").Value
'etc, etc,

oRS.MoveNext

'updates the recordset and the table
oRS.Update
Next


"If i was king cigarettes would be free."


GeneralRe: vb.net Excel file to SQL table Pin
partt3-Sep-04 3:28
partt3-Sep-04 3:28 
GeneralRe: vb.net Excel file to SQL table Pin
partt3-Sep-04 8:34
partt3-Sep-04 8:34 
General2 Component questions Pin
RoyRose782-Sep-04 6:57
RoyRose782-Sep-04 6:57 
GeneralRe: 2 Component questions Pin
Dave Kreskowiak2-Sep-04 9:48
mveDave Kreskowiak2-Sep-04 9:48 
GeneralQuestion on comparing data Pin
albert20042-Sep-04 6:36
albert20042-Sep-04 6:36 
GeneralVB.NET DDE project Pin
valdo772-Sep-04 2:32
valdo772-Sep-04 2:32 
GeneralRe: VB.NET DDE project Pin
Dave Kreskowiak2-Sep-04 5:19
mveDave Kreskowiak2-Sep-04 5:19 
GeneralhanksTreeView Pin
Member 12256032-Sep-04 0:59
Member 12256032-Sep-04 0:59 
GeneralRe: hanksTreeView Pin
Dave Kreskowiak2-Sep-04 4:58
mveDave Kreskowiak2-Sep-04 4:58 
GeneralBuild Failures Pin
beowulfagate2-Sep-04 0:26
beowulfagate2-Sep-04 0:26 
GeneralRe: Build Failures Pin
Chris Quick2-Sep-04 2:28
Chris Quick2-Sep-04 2:28 
GeneralRe: Build Failures Pin
Jim Matthews2-Sep-04 2:46
Jim Matthews2-Sep-04 2:46 
GeneralRe: Build Failures Pin
beowulfagate2-Sep-04 13:38
beowulfagate2-Sep-04 13:38 
GeneralRe: Build Failures Pin
Jim Matthews2-Sep-04 17:00
Jim Matthews2-Sep-04 17:00 
GeneralRSA Decryption code example VB6 Pin
gpcare1-Sep-04 23:23
gpcare1-Sep-04 23:23 
GeneralRe: RSA Decryption code example VB6 Pin
Dave Kreskowiak2-Sep-04 4:52
mveDave Kreskowiak2-Sep-04 4:52 
GeneralAdding new items through Combobox Pin
ralphz1-Sep-04 23:12
ralphz1-Sep-04 23:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.