字符串,案例和查询的 [英] strings, cases and query's
问题描述
您好,我已经完成了以下项目:
我已经制作了V卡,可以将其导入到数据库中,但是
我无法显示我想要的所有信息.
这是我的代码的某些部分:
hello, i have the made the following project:
I have made a V-Card, I can import this into my database but,
I can not show all the information I want..
Here is some parts of my code:
'Private Sub voor het importeren van een V-Card:
Private Sub Importeren() _
Handles itemImporteerVCard.Click, mnuImportVCard.Click, _
btnImportVCard.Click 'Alle knoppen voor het importeren.
Dim strBestand As String = String.Empty 'Locatie + naam van het bestand.
Dim strRegel As String = String.Empty 'Regel/lijn.
Dim strWaarde() As String = Nothing 'de inhoud van de regels/lijnen.
Dim objReader As System.IO.StreamReader = Nothing, _
sbBuilder As System.Text.StringBuilder = Nothing
'Variabelen:
'--------------------------------
Dim intNummer As Integer = "111114" 'een nummer kan maar één keer voorkomen.
Dim strSoort As String = "D" 'D = Debiteuren, C = Crediteuren, R = Relaties.
Dim strNaam As String = " " 'de naam die in de V-Card staat.
Dim strVoornaam As String = " " 'Voornaam.
Dim strTelefoon As String = " " 'Deze String moet nog aangepast worden,
Dim strTelWerk As String = " " 'strTelwerk en strTelThuis zijn samen strTelefoon.
Dim strTelThuis As String = " "
Dim strMobiel As String = " " 'Mobiel nummer.
Dim strOverig As String = " " 'Overige telefoon nummers.
Dim strFax As String = " " 'Ook hier worden strFaxWerk + Thuis samen strFax.
Dim strFaxWerk As String = " "
Dim strFaxThuis As String = " "
Dim strAdres As String = " "
Dim strPostcode As String = " "
Dim strPlaats As String = " "
Dim strAdresgegevens As String = (strAdres) & (strPostcode) & (strPlaats)
Dim strWebsite As String = " "
Dim strUrlThuis As String = " "
Dim strUrlWerk As String = " "
Dim strMail As String = " "
Dim strZoek As String = "testtest"
那是我的字符串,在这里,我将这些字符串导入了大小写中:
That are my strings and here I have import thes strings into cases:
'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" 'De waarden die niet worden getoond.
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:" 'Adres.
strAdresgegevens = 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
下一步是将INERT INTO数据库:
The Next step is to INSERT INTO Database:
'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_mobielnr, B22_faxnummer, " _
& "B22_email, B22_www_adres, B22_zoeknaam) " _
& " VALUES (" & intNummer & ", '" & strSoort & "', '" & strNaam & "', '" & strVoornaam _
& "', '" & strAdres & "', '" & strPostcode & "', '" & strPlaats & "', '" & strTelefoon _
& "', '" & strMobiel & "', '" & strFax & "', '" & strMail & "', '" & strWebsite & "', '" & strZoek & "' )"
Dim ds_B22 As New OdbcCommand 'ds_B22 is de tabel Relaties.
ds_B22.CommandType = Data.CommandType.Text
ds_B22.CommandText = strInsert
ds_B22.Connection = cnn
ds_B22.ExecuteNonQuery()
这是我在运行应用程序时无法显示的信息:
strAdres,strPostcode,strPlaats->必须是一个字符串
StrutsThuis& strTelWerk->必须是一个字符串
strFaxThuis& strFaxWerk->必须是一个字符串
电子邮件和str网站->必须是一个字符串.
你知道我该怎么做吗?
谢谢.
This is the info I can not show when I run the app:
strAdres, strPostcode, strPlaats -> must be one string
strTelThuis & strTelWerk -> must be one string
strFaxThuis & strFaxWerk -> must be one string
strEmail & strWebsite -> must be one string.
do you know how i can do this?
thanks.
推荐答案
我建议使用string.format函数.例如,我为您提供地址:
I recommend using the string.format function. For you address for example I would :
String.Format("{0}, {1}, {2}", strAdres, strPostcode, strPlaats)
OdeJong,哪里出了问题?
要连接字符串,请使用:
OdeJong, where is a problem?
To concate strings, use:
sStrConcat = sString1 & sString2
或 StringConcat [
or StringConcat[^] method.
Based on your code:
Example 1:
strInsert = "INSERT INTO Relaties (B22_relnr, B22_rel_soort, B22_naam, B22_voornaam_etc, " _
& "B22_adres, B22_postcode, B22_plaats, B22_telefoon1, B22_mobielnr, B22_faxnummer, " _
& "B22_email, B22_www_adres, B22_zoeknaam) " _
& " VALUES (" & intNummer & ", '" & strSoort & "', '" & strNaam & "', '" & strVoornaam _
& "', '" & strAdres & strPostcode & strPlaats "', '" & strPostcode & "', '" & strPlaats & "', '" & strTelefoon _
& strTelThuis & strTelWerk & "', '" & strMobiel & "', '" & strFax & strFaxThuis & strFaxWerk & "', '" & strMail & "', '" & strWebsite & "', '" & strZoek & "' )"
'and so on...
MessageBox (strInsert)
示例2:
Example 2:
MessageBox (String.Concat(strAdres, String.Concat(strPostcode, strPlaats)))
阅读有关以下内容的更多信息:操作员 [
Read more about: Operators[^]
这篇关于字符串,案例和查询的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!