Avatar billede dandare Nybegynder
18. marts 2002 - 14:59 Der er 15 kommentarer og
1 løsning

Visual Basic -> Access INSERT

Hej Alle!

Jeg er igang med at lave et plug-in i VB til WinAMP, hvor jeg registrerer alle mine MP3 filer i en database.

Jeg lægger data ind i databasen (access2000) ved at opbygge en query i VB og derefter indsætte data'erne.

Problemet opstår når jeg vil indsætte specialtegn bla. ->'<-

eks:
INSERT into songtitle (title) values ('I'm here')

Hvordan løser jeg dette problem?

På forhånd tak,

Daniel
Avatar billede terry Ekspert
18. marts 2002 - 15:00 #1
INSERT into songtitle (title) values ("I'm here")
18. marts 2002 - 15:03 #2
Eller:
"INSERT into songtitle (title) values ('I" & Chr(39) & "m here')"
Avatar billede terry Ekspert
18. marts 2002 - 15:05 #3
"INSERT into songtitle (title) values (""I'm here"")"
Avatar billede dandare Nybegynder
18. marts 2002 - 18:44 #4
Tak for jeres svar, men jeg har åbenbart ikke forklaret mig godt nok. Problemet er ikke Visual Basic koden, men problemet er SQL sætningen. Hvis man ser helt bort fra Visual Basic koden og bare kigger på SQL'en, er der stadigvæk samme problem som før, nemlig specialtegn, men denne gang bare i SQL.

Skal jeg uddybe mere...

Daniel
Avatar billede dandare Nybegynder
18. marts 2002 - 19:00 #5
Hej alle!

Jeg har løst problemet!!!

Hvis man skal bruge tegnet ' i SQL, og det bare skal tolkes som tekst, så skal man have 2 af dem lige efter hinanden.

eks.

INSERT into songtitle (title) values ('I''m here')

I databasen vil der stå: I'm here

Tak for jeres tid :-)

Daniel
Avatar billede terry Ekspert
18. marts 2002 - 20:16 #6
dandare>the answer I gave 15:05 DOES work as shown, also your solution will work, but takíng the points yourself isnt ON! you cant expect people to help if you just run off and make another solution!
Avatar billede dandare Nybegynder
19. marts 2002 - 10:22 #7
Hi terry!

I'm sorry terry, it was'nt meant to be like that...

I've tested your solution and it does NOT work!!! so I can't give you any points for that.

As a comment: I apprechiate your help, but I will reserve the right to come up with a solution on my own. The reason for posting my solution was in case someone else might have the same problem. I don't care about the points, I care about getting my code to work and HELPING others...

dandare
Avatar billede dandare Nybegynder
19. marts 2002 - 10:37 #8
A quick comment:

The reason terry's solution from 15:05 does NOT work is that doublequotes is not allowed in SQL as a marker of a textstring.

There u go...
Avatar billede terry Ekspert
19. marts 2002 - 11:15 #9
strange but I did this in SQLL Server 2000 and it DID work, or I wouldnt have stated 15:05 that it did!
Avatar billede terry Ekspert
19. marts 2002 - 11:17 #10
Sorry! getting things mixed up here, I HAVE not tested in in SQL I HAVE tested it in Access as this WAS Access and no mention of SQL Server
Avatar billede dandare Nybegynder
19. marts 2002 - 11:36 #11
Yes u are getting things mixed up.

It's the SQL statment that was the malfunctioning part.
It does'nt matter if it is an Access or (Microsoft???)SQL database or any database, as long as it is an SQL compliant database.
The reason I mentioned the Access database was that I'm using it as a back-end. The front-end is made in VisualBasic. So the resolution posted 15:05 might work directly in access, but it will not work from the VisualBasic SQL query.
Avatar billede terry Ekspert
20. marts 2002 - 19:25 #12
dandare>can you place an answer yourself so that we can get the question out of the way please?
Avatar billede dandare Nybegynder
21. marts 2002 - 08:49 #13
I already did... 19:00:09.....case closed ;-)
Avatar billede terry Ekspert
21. marts 2002 - 09:20 #14
dandare>I dont think I like your tone! We are here to help each other, but we also dont know everything! Even so comments and answers given, even though they may NOT be exactly what the customer wants, may help "get the grey cells workink", which actually seems to be the case here! The reason why I asked you to place an answer (not a comment) is so that you can accept it yourself and get your points back, and also to get the question removed from the "still not answered list". I cant see that needs to be a problem, can you?
Avatar billede mugs Novice
21. marts 2002 - 21:04 #15
Vi har flere gange oplevet, at selv seriøse brugere er gået fejl af hinanden, såvel på grund af spørgsmålets og / eller svarets formulering, der måske ikke er i en "syntaks" der tiltaler brugeren.

I dette tilfælde er det spørgerens kommentar 21/03 kl 08:49:12, der er kilden til en spirende uenighed. "Case is not Closed" før der er et accepteret svar. Terry har hel ret, når han anmoder spørgeren om at oprette et svar og ikke blot en kommentar.

Først da er "Case closed".
Avatar billede dandare Nybegynder
22. marts 2002 - 10:24 #16
Geez terry r u highstrung or ...

Well an apology goes to terry, this is the first time I've posted a question here, so I'm not familiar with the rutine. So I was not aware of that an answer needed an accept. So SORRY terry!!!!

And the points go to.........terry!!!! (for persistance)

Thank you SO much for your help :-)
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester