Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with importing from excel

Status
Not open for further replies.

vbpadawan

Programmer
Oct 8, 2002
28
US
In my code, I import data from an excel worksheet into a SQL table. My code has worked fine up until yesterday. I haven't made any changes to my code and my customer says that they haven't made any format changes to the worksheet. The problem is when I open the recordset with my excel data, the last column (which is a time field) is NULL in the recordset. I looked in the worksheet and there is data in all of the records in this column. Here is my code:

Private Sub ImportData(ByVal sFile As String)
On Error Resume Next
Dim oRS As ADODB.Recordset
Dim oField As ADODB.Field

Dim sConn As String
Dim sXL As String
Dim sDriver As String
Dim sSheet As String
Dim strRates As String

Dim bAddRecord As Boolean
Dim cnt As Long

Dim rsRates As New ADODB.Recordset

sDriver = "278"

sXL = sFile

sSheet = "Sheet1"

sConn = "Driver={Microsoft Excel Driver (*.xls)}; " & _
"DBQ=" & sXL & "; " & _
"DriverID=" & sDriver

Set oRS = New ADODB.Recordset
oRS.Open "SELECT * FROM `" & sSheet & "$`", _
sConn, _
adOpenStatic, _
adLockReadOnly
do until ors.EOF
Debug.Print oRS!col1& " " & oRS!col2
& " " & oRS!col3 & " " & oRS!col4 & " " &
oRS!col5 & " " & oRS!col6 & " " &
oRS!code & " " & oRS!EffectiveDate
& " " & oRS!effectivetime

oRS.MoveNext
Loop

End With

oRS.Close
Set oRS = Nothing

MousePointer = vbDefault

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top