Avatar billede weezy121 Nybegynder
27. august 2008 - 10:28 Der er 2 kommentarer

ASP.NET insert i Formview

jeg kan godt edit og delete i mit formview, men når jeg skal til at insert noget skriver den det her:


You tried to assign the Null value to a variable that is not a Variant data type.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.Ole Db.OleDbExcepti on: You tried to assign the Null value to a variable that is not a Variant data type.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

det er en access 2000 (mdb) database, er der en knap, så man kan give den lov til at indsæt noget i databasen...

min insert commando, se sådan ud...
InsertCommand=" INSERT INTO produkt(Id, Knallert, Kmt, Pris, Lev, Billede1, Billede2, Billede3) VALUES (Id, Knallert, Kmt, Pris, Lev, Billede1, Billede2, Billede3)"

sig til hvis i skal bruge mere info... er meget ny til asp.NET, men er kendt i Html og php
Avatar billede terry Ekspert
27. august 2008 - 13:05 #1
I know very little about ASP.NEt but I think I can see the problem.

Take a look at your insertCommand
If the VALUES are variables then you need to alter the code so that the contents of the variables are written to insertCommand. At the moment you are writing th ename of the variables.
And variables which are to be written to text (type) fields in the dB need to be enclosed in ''

So that your insertCommand will end up looking something like this


INSERT INTO produkt(Id, Knallert, Kmt, Pris, Lev, Billede1, Billede2, Billede3) VALUES (1, 'Knallert', 12345, 99999, '2008-08-27', 'Link to Billede1', 'Link to Billede2', 'Link to Billede3')"

Also its an idea (if thats what your trying to do) to NOT write picture fiels to the dB as they fill so much, but instead write the path/filename.
Avatar billede terry Ekspert
27. august 2008 - 13:10 #2
picture fiels = picture files
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