oke eerst ff de code:
Den 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:
En nu de vraag?
Er is iets mis met mijn INSERT commando maar ik vind het niet
Het moet weer zoiets stoms zijn - zoals meestal!
Ik heb al een paar keer alles doorlopen en de code herschreven maar niets...
Wat moet ik veranderen het gaat dus over de Functie in mijn code!
Visual Basic .NET:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
| <%@ Page Language="VB" Debug="True" %> <%@ import Namespace="System.IO" %> <%@ import Namespace="System.Data" %> <%@ import Namespace="System.Data.OLEDB" %> <%@ import Namespace="microsoft.visualbasic" %> <%@ import Namespace="System.Drawing" %> <script runat="server"> Sub UploadBtn_Click(Sender as Object, E as EventArgs) Dim imgStream as Stream Dim imgLen as Integer Dim imgName_value as string Dim imgContentType as String Dim imgUploadedName as String imgStream = UploadFile.PostedFile.InputStream imgLen = UploadFile.PostedFile.ContentLength imgUploadedName = UploadFile.PostedFile.FileName Dim imgBinaryData(imgLen) as Byte imgContentType = UploadFile.PostedFile.ContentType imgName_value = imgName.Value Try If imgName_value.Length < 1 then imgName_value = GetLastRightOf("\",imgUploadedName ) End if Catch myEx as Exception imgName_value = GetLastRightOf("\",imgUploadedName ) End Try Dim n as Integer = imgStream.Read(imgBinaryData, 0, imgLen) Dim NumRowsAffected as Integer = MyDatabaseMethod(imgName_value, imgBinaryData, imgContentType) If NumRowsAffected > 0 then Response.Write ( "<BR> Yeaaaahhhhhhhhh tis gelukt!!! " ) Else Response.Write ( "<BR> Daammnn, mislukt " ) End if End Sub Function GetLastRightOf(LookFor as String, myString as String) as String Dim StrPos as Integer StrPos = myString.LastIndexOf(LookFor) Return myString.SubString(StrPos + 1) End Function 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 </script> <html> <head> <title>Upload Images to a Database</title> </head> <body> <form id="form1" name="form1" enctype="multipart/form-data" runat="server"> Den titel plz: <input id="imgName" type="text" runat="server" /> <br /> En welk bestandje? <input id="UploadFile" type="file" runat="server" /> <asp:button id="Button1" onclick="UploadBtn_Click" runat="server" Text="En me een beetje geluk.."></asp:button> </form> </body> </html> |
Den 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:
En nu de vraag?
Er is iets mis met mijn INSERT commando maar ik vind het niet
Het moet weer zoiets stoms zijn - zoals meestal!
Ik heb al een paar keer alles doorlopen en de code herschreven maar niets...
Wat moet ik veranderen het gaat dus over de Functie in mijn code!
[ Voor 10% gewijzigd door Verwijderd op 15-01-2003 21:19 ]