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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading excel issues

Status
Not open for further replies.

NewbiDoobie

Technical User
Jul 25, 2005
63
US
I am trying to read information from an excel spreadsheet to place them into a database.

Problemn I am having is that I cannot seem to read a comma delimted Cell. I only want to import it as a text field, but every time i walk through that cell it puts it in as a blank.

Why is this such a huge issue if I only want to read it as a string value? Why Cannot I read this cell with VB, SQL Server or Access? None of these are working.

ID OldValue NewValue
1 123,old 123, 124, 125
2 All 195 Codes P195, C195, D195
Code:
Dim Coder As String
Dim ROKey1 As Integer
Dim CONN As ADODB.Connection
Dim RS As ADODB.Recordset
Dim SQL As String
Set CONN = New ADODB.Connection
Set RS = New ADODB.Recordset
CONN.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
           "Data Source=C:\DEVDatabases\RTDiagCodes2.xls;" & _
           "Extended Properties=""Excel 8.0;HDR=Yes"""
With RS
    .Open "SELECT * FROM [Sheet1$]", CONN, adOpenDynamic, adLockOptimistic
    .MoveFirst
End With
Do Until RS.EOF
ROKey.Text = RS.Fields(0)

ROKey1 = RS.Fields(0)
Coder = CStr(RS.Fields(2))

'ROKey1 = 1
'Coder = "test"
SQL = " insert into HACodeListXref Values( '" & ROKey1 & "','" & Coder & "')"
NewCode.Text = SQL
 'Codeer = CStr(RS.Fields(0)) + " " + CStr(RS.Fields(2))
 DbConnect.Execute (SQL)

    RS.MoveNext
Loop
MsgBox "Done"
 


Hi,

Are you sure that there are [SPACES] between the [Comma] and digit? Could be interpreting as thousands separators of a NUMBER TEXT and NUMBERS in the same column are like oil and water using SQL.

Skip,

[glasses] [red]A palindrome gone wrong?[/red]
A man, a plan, a ROOT canal...
PULLEMALL![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top