Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2003
    Posts
    7

    Talking Unanswered: Junior developer in need of help....

    First.. I'm NOT an Excel guy. NO VBA please! This must be in VB6 code.

    Now then .. :-)

    I get sent an excel file from a client. Sometimes it is multiple worksheets. I have an existing VB6 application running on MS SQL Server database.

    I need to open each record in the Excel file, which is checked via email address...

    If an email address already exists in SQL - flag the user with a warning message.....

    If an email address does not exist - generate new unique identifyer and update the spreadsheet with this new ID....

    I need some specific example code, and not (necessarily) pointers to KB articles, etc. This is my FIRST time dealing with this subject, so PLEASE be kind.

    Thank you for your help -....

  2. #2
    Join Date
    Nov 2003
    Location
    FRANCE
    Posts
    393

    Re: Junior developer in need of help....

    This is a VB question not an SQL Server one...

    I can give you code to :
    - read files
    - connect to a database
    - insert rows in a table

    does this interest you ?

  3. #3
    Join Date
    Nov 2003
    Posts
    7

    Re: Junior developer in need of help....

    Originally posted by Karolyn
    This is a VB question not an SQL Server one...

    I can give you code to :
    - read files
    - connect to a database
    - insert rows in a table

    does this interest you ?
    As a matter of interest - the code to read files would be great.....

    Thanks for the help....
    Have a good day...

  4. #4
    Join Date
    Nov 2003
    Location
    FRANCE
    Posts
    393

    Re: Junior developer in need of help....

    Set oFso = New FileSystemObject

    Set TS = oFso.OpenTextFile('c:\yourfile.xls')

    strReq = vbNullString

    Do While Not TS.AtEndOfStream
    strLigne = Trim(TS.ReadLine)
    If UCase(strLigne) = FIN_SQL Then
    'Call MsgBox(strReq, vbInformation, "Commande")
    Set oQueryResult = oSQLServer.Databases(NOM_BASE).ExecuteWithResults( strReq)
    strReq = vbNullString
    ElseIf strLigne <> vbNullString Then
    strReq = strReq & strLigne & vbCrLf
    End If
    Loop

    Call TS.Close

    Set oFso = Nothing

  5. #5
    Join Date
    Nov 2003
    Location
    FRANCE
    Posts
    393

    Re: Junior developer in need of help....

    Set oFso = New FileSystemObject

    Set TS = oFso.OpenTextFile('c:\yourfile.xls')

    strReq = vbNullString

    Do While Not TS.AtEndOfStream
    strLigne = Trim(TS.ReadLine)
    If UCase(strLigne) = FIN_SQL Then
    'Call MsgBox(strReq, vbInformation, "Commande")
    Set oQueryResult = oSQLServer.Databases(NOM_BASE).ExecuteWithResults( strReq)
    strReq = vbNullString
    ElseIf strLigne <> vbNullString Then
    strReq = strReq & strLigne & vbCrLf
    End If
    Loop

    Call TS.Close

    Set oFso = Nothing

  6. #6
    Join Date
    Nov 2003
    Location
    FRANCE
    Posts
    393

    Re: Junior developer in need of help....

    the last message is not finished ...!
    someone clicked on submit...
    bad joke

    the finished answer will come soon

  7. #7
    Join Date
    Nov 2003
    Location
    FRANCE
    Posts
    393

    Re: Junior developer in need of help....

    1) ------------------------------------------------------
    you'll need a reference on the Microsoft scripting runtime

    2) ------------------------------------------------------
    Dim oFso As FileSystemObject
    Dim TS As TextStream
    Dim strEmail As String

    Set oFso = New FileSystemObject

    Set TS = oFso.OpenTextFile('c:\yourfile.xls')

    Do While Not TS.AtEndOfStream
    strEmail = Trim(TS.ReadLine) 'this is where you get you lines
    if DataBaseContains(strEmail) then
    call MsgBox("Already exists")
    else
    call InsertIntoDataBase(strEmail)
    endif
    Loop

    Call TS.Close

    Set oFso = Nothing

    3) ------------------------------------------------
    Create the function DataBaseContains(strEmail)

    4) ------------------------------------------------
    Create the Sub InsertIntoDataBase(strEmail)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •