Toon posts:

[ASP.net] Insert error ?

Pagina: 1
Acties:

Verwijderd

Topicstarter
Oke, mijn vorige topic werd gesloten (mijn schuld had 100 regels code ingegeve) dus ik post ff een nieuw. 't Is een beetje tegen de regels maar dit topic zal de P&W-faq volgen :) .

Dus eerst de code:
Visual Basic .NET:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Function MyDatabaseMethod(imgName As String, imgbin As Byte(), imgcontenttype as String) As Integer 
Dim strConnection As String = "Provider=Microsoft.Jet.OleDb.4.0;data source=" & server.mappath("\bin\games.mdb") & ";" 
Dim connection As OleDbConnection = New OleDbConnection(strConnection) 
Dim command as New OleDbCommand( "Insert into Screens (Image, contenttype, Beschrijving) Values ( @Image, @Contenttype, @Beschrijving )", connection )



command.Parameters.Add( "@Image", imgbin ) 
command.Parameters.Add( "@Beschrijving", imgName ) 

command.Parameters.Add( "@Contenttype", imgcontenttype ) 

connection.Open() 
Dim numRowsAffected as Integer = command.ExecuteNonQuery() 
connection.Close() 

Return numRowsAffected 

End Function 


De volledige code staat op [rml][ ASP.net] Zoek de fout :)[/rml]

Nu geeft dit deze error:
Syntax error in INSERT INTO statement.
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.OleDb.OleDbException: Syntax error in INSERT INTO statement.

Source Error:


Line 62:
Line 63: connection.Open()
Line 64: Dim numRowsAffected as Integer = command.ExecuteNonQuery()
Line 65: connection.Close()
Line 66:

Ik heb mijn sql code al een paar keer nagekeken maar ik vind niets dat fout lijkt |:(
Het zit dus in deze regel; denk ik:
Dim command as New OleDbCommand( "Insert into Screens (Image, contenttype, Beschrijving) Values ( @Image, @Contenttype, @Beschrijving )", connection )

Ziet iemand wat er mis zou kunnen zijn?

  • whoami
  • Registratie: December 2000
  • Nu online
Heb je m'n vorige tips al eens uitgevoerd?

Het sql-statement eens zo uitvoeren, dus niet in je ASP.NET code, maar rechtstreeks naar de databank.

Je probleem zet hem volgens mij bij je parameters.
Je doet:
code:
1
command.Parameters.Add ("@param1", imgname)


Herschrijf dat eens als volgt:
code:
1
2
3
command.Parameters.Add ("@param1", OleDbType.VarChar)  // specifieer wel het juiste type
command.Paramaters["@param1"].Value = imgname
command.ExecuteNonQuery()

https://fgheysels.github.io/


Verwijderd

Topicstarter
zal et morgen proberen server lijkt plat te liggen :s

  • whoami
  • Registratie: December 2000
  • Nu online
?
Heb je geen IIS op je PC lokaal staan?
Kan je niet lokaal testen dan?

https://fgheysels.github.io/


Verwijderd

Topicstarter
Nu komt er nog een andere error |:(

Compiler Error Message: BC30545: Property access must assign to the property or use its value.
Source Error:
Line 61: ' command.Parameters.Add( "@Contenttype", imgcontenttype )
Line 62: command.Parameters.Add ("@Image", OleDbType.binary)
Line 63: command.Parameters["@Image"].Value = imgbin
Line 64:
Line 65: command.Parameters.Add ("@Beschrijving", OleDbType.varchar)


BTW typo: paramEters ;)

[ Voor 89% gewijzigd door Verwijderd op 17-01-2003 18:36 ]

Pagina: 1