Click here to Skip to main content
15,894,106 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hello,

this is my last chance.. it's still not working.
I will try to explain it simple:

I have a database
I have a textfile (vcf)
my App shows the info that is in the database.

I want to import the textfile show there will be a new contact show in my app saved in the database.

this is the info in the textfile:

CSS
BEGIN:VCard
VERSION:2.1
N:De Jong
FN:Anne
TEL;WORK;VOICE:0512540540
TEL;WORK;VOICE:0512540540
TEL;HOME;VOICE:06-11299731
TEL;CELL;VOICE:06-11299731
TEL;VOICE:0512 540221
TEL;WORK;FAX:0512 540540
TEL;FAX:0512 540221
ADR;WORK;PREF:;;Sjoerd Veltmanstraat 15;Drachten;;9203 NJ
ENCODING=QUOTED-PRINTABLE:Sjoerd Veltmanstraat 15
URL;HOME:www.epixfotostudio.nl
URL;WORK:www.epixfotostudio.nl
EMAIL;PREF;INTERNET:odejong@epixfotostudio.nl
END:VCARD


From N till Fax is inserted into the database.

From the Adres will not be inserted. This is my code to insert:

VB
Do While objReader.Peek >= 1
    strRegel = objReader.ReadLine(1)             'Elke regel/lijn wordt 1 voor 1 gelezen:
    strWaarde = strRegel.Split(":")             'De waarde van elke regel wordt gesplits d.m.v. ":":
    strWaarde = strRegel.Split(";")
    'strAdgegevens = strAdwaarde.Split(";")
    'Onderstaande Boolean zorgt ervoor dat dubbele info weg gehaald worden:
    '----------------------------------------------------------------------
    Dim blnDubbel As Boolean

    Select Case UCase(strWaarde(0))             '(0) = het gedeelte voor ":" en (1) komt daarna:
        Case "BEGIN", "VERSION", "END", _
             "ENCODING=QUOTED-PRINTABLE"

        Case "N"
            strNaam = strWaarde(1)
            sbBuilder.Append(strWaarde(1) & vbTab)

        Case "FN"                               'Voornaam:
            strVoornaam = strWaarde(1)
            sbBuilder.Append(strWaarde(1) & vbCrLf)

        Case "TEL;WORK;VOICE"                   'Telefoon op het werk:
            If blnDubbel = False Then

                strTelWerk = strWaarde(1)
                sbBuilder.Append(strWaarde(1) & vbTab)
                blnDubbel = True
            End If

        Case "TEL;HOME;VOICE"                   'Telefoon thuis:
            strTelThuis = strWaarde(1)
            sbBuilder.Append(strWaarde(1) & vbCrLf)

        Case "TEL;CELL;VOICE"                   'Mobiele telefoon:
            strMobiel = strWaarde(1)
            sbBuilder.Append(strWaarde(1) & vbTab)

        Case "TEL;VOICE"                        'Overige nummers:
            strOverig = strWaarde(1)
            sbBuilder.Append(strWaarde(1) & vbCrLf)

        Case "TEL;WORK;FAX"                     'Fax op het werk:
            strFaxWerk = strWaarde(1)
            sbBuilder.Append(strWaarde(1) & vbTab)

        Case "TEL;FAX"                          'Fax thuis:
            strFaxThuis = strWaarde(1)
            sbBuilder.Append(strWaarde(1) & vbCrLf)

        Case "ADR;WORK;PREF:"                  'Adresgegevens:
            strAdgegevens = strWaarde(1)
            sbBuilder.Append(strWaarde(1) & vbCrLf)

        Case "URL;HOME:"                        'Website Thuis:
            strUrlThuis = strWaarde(1)
            sbBuilder.Append(strWaarde(1) & vbTab)

        Case "URL;WORK:"                        'Website Werk:
            strUrlWerk = strWaarde(1)
            sbBuilder.Append(strWaarde(1) & vbCrLf)

        Case "EMAIL;PREF;INTERNET:"             'Email adres:
            strMail = strWaarde(1)
            sbBuilder.Append(strWaarde(1))

        Case Else
            sbBuilder.Append(strWaarde(1) & vbCrLf)

    End Select
Loop                                            'Het proces wordt herhaald:
objReader.Close()
frmVCard.txtVCard.Text = sbBuilder.ToString

Dim strInsert As String

'Waardes invoegen in de velden van de tabel Relaties:
'----------------------------------------------------
'INSERT & VALUES lijst:

strInsert = "INSERT INTO Relaties (B22_relnr, B22_rel_soort, B22_naam, B22_voornaam_etc, " _
 & "B22_adres, B22_postcode, B22_plaats, B22_telefoon1, B22_telefoon2, " _
 & "B22_mobielnr, B22_faxnummer, B22_email, B22_www_adres, B22_zoeknaam) " _
 & " VALUES (" & intNummer & ", '" & strSoort & "', '" & strNaam _
 & "', '" & strVoornaam & "', '" & strAdres _
 & "', '" & strPostcode & "', '" & strPlaats & "', '" & strTelWerk _
 & "', '" & strTelThuis & "', '" & strMobiel & "', '" & strFaxWerk _
 & "', '" & strMail & "', '" & strUrlWerk & "', '" & strZoek & "' )"

Dim ds_B22 As New OdbcCommand                       'ds_B22 is de tabel Relaties.
ds_B22.CommandType = Data.CommandType.Text
ds_B22.CommandText = strInsert      'Zorgt ervoor dat de informatie wordt toegevoegd aan de database.
ds_B22.Connection = cnn
ds_B22.ExecuteNonQuery()

If MsgBox _
    ("De V-Card is geïmporteerd", 0, "V-Card is geïmporteerd") Then

    Exit Sub
End If



I hope someone can help me out.
I have download a vcf file from this forum but I still dont get it.
just give me an example to show how to get the info into the database.
Thanks
Posted
Comments
[no name] 29-Jun-12 10:04am    
Like I told you before in your 6th repost of this question, "it's still not working" is not a helpful description of your problem. What exactly is not working? The address? What is the value of "strAdgegevens" when you debug your code? What is the value of "strAdres" when you go to insert all of this in your database? And you should be using parameterized queries instead of all this string concatenation. Why do you split the address to a variable named "strAdgegevens" and then not use it? Most of all, why have you ignored the answers that you have already been given?
OdeJong 2-Jul-12 2:27am    
I don't ignore the answers, I try them all. And I explained many times what my purpose is. I wil try something else then

The first thing that jumps out at me is the fact that you are overwriting your strWaarde variable. My guess is that if you comment out the second assignment to that variable that you will fix your issue. Here is what it should look like:

VB
strRegel = objReader.ReadLine(1)
strWaarde = strRegel.Split(":") 
'strWaarde = strRegel.Split(";")


The commented out line would split the line the wrong way. You need to split it at the colon, not the semi-colon since you are expecting to look at the strWaarde(0) value for the entire identifier portion, not just the first part of it.
 
Share this answer
 
Comments
OdeJong 29-Jun-12 10:07am    
Sorry. I still don't understand it. I have set the comment out but then i Get a Error that the bound is out of array..

Index was outside the bounds of the array
my project is done!
everyone thanks for your help
 
Share this answer
 
My project is done!
thanks everyone for your help!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900