Toon posts:

[asp/VB] sql verbinding --> mdb verbinding *

Pagina: 1
Acties:

Verwijderd

Topicstarter
wie kan deze verbinding voor mij omzetten ??? ben zelf aan t kloten geweest en t wil maar niet lukken:

om te zetten code
<%
Server.ScriptTimeout = 50000
Set upl = Server.CreateObject("SoftArtisans.FileUp")
if upl.ContentType = "image/gif" or upl.ContentType = "image/pjpeg" or upl.ContentType = "audio/mpeg" or upl.ContentType = "application/x-zip-compressed" or upl.ContentType = "application/msword" then
NewFileName = Mid(upl.UserFilename, InstrRev(upl.UserFilename, "\") + 1)
Description = replace(Upl.Form("Description"),"'","''")
Size = upl.TotalBytes
upl.SaveinVirtual NewFileName
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.ConnectionString = "DSN=DMG"
Conn.open
sql = "Insert into Files (Name,Description,Size,Uploader,Dateuploaded) Values ('" & NewFileName & "','" & Description & "','" & Size & "'," & Session("memberid") & ",'" & now & "')"
Conn.execute sql
Conn.close
Set Conn = Nothing
set upl = nothing
end if
response.redirect("../uploadfile.asp")
%>
[/code]

mijn verbinding
<%

Dim DB_CONNSTRING
DB_CONNSTRING = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.Mappath("Admin/Database/Database_algemeen.mdb") & ";"
Dim rsCount ' The recordset object
Set rsCount = Server.CreateObject("ADODB.Recordset")
' rsCount.Open "onderdelen" ---> zoekt naar de betreffende tabel.
rsCount.Open "onderdelen", DB_CONNSTRING, adOpenStatic, adLockReadOnly, adCmdTable
Response.Write rsCount.RecordCount
Response.Write " Onderdelen in onze database." & vbCrLf

%>
[/code]

thnx ;)

Verwijderd

misschien kan je even vertellen wat er wel/niet lukt ipv doe dit nou effe voor mij

  • raptorix
  • Registratie: Februari 2000
  • Laatst online: 17-02-2022
heej dat lijkt mijn code wel ;)

Je hoeft inprincipe alleen dit regeltje te veranderen :

Conn.ConnectionString = "DSN=DMG"

Als je direct naar mdb file wilt verwijzen zoek dan even op dsnless connection

Verwijderd

Topicstarter
had hm zo al klaar:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<%
Server.ScriptTimeout = 50000
Set upl = Server.CreateObject("SoftArtisans.FileUp")
upl.Path = "g:\activewebroot\00321\w00321988\Admin\Schadeauto's" 
if upl.ContentType = "image/gif" or upl.ContentType = "image/pjpeg" or  upl.ContentType = "audio/mpeg" or  upl.ContentType = "application/x-zip-compressed" or  upl.ContentType = "application/msword" then
NewFileName = Mid(upl.UserFilename, InstrRev(upl.UserFilename, "\") + 1)
Description = replace(Upl.Form("Description"),"'","''")
Size = upl.TotalBytes
upl.SaveinVirtual NewFileName

Dim DB_CONNSTRING
DB_CONNSTRING = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.Mappath("Admin/Database/Database_algemeen.mdb") & ";"
Dim rsCount ' The recordset object
Set rsCount = Server.CreateObject("ADODB.Recordset")

rsCount = "Insert into Files (Name,Description,Size,Uploader,Dateuploaded) Values ('" & NewFileName & "','" & Description & "','" & Size & "'," & Session("memberid") & ",'" & now & "')"

rsCount.Close
Set rsCount = Nothing
set upl = nothing
end if
response.redirect("default.asp")
%>

maar zo upload die niet en zet hij de locatie niet in een database.... ( das de bedoeling |:( )

Ps raptorix THNX maar:
Je zoekactie naar 'dsnless connection' leverde geen resultaten op. Resultaten 1 - geen.
;)

Verwijderd

Wat is de fout melding die je terug krijgt

edit:

Ja, nu wel code en /code

  • raptorix
  • Registratie: Februari 2000
  • Laatst online: 17-02-2022
Als je direct in DB wilt uploaden moet je even kijken naar de voorbeeldscriptjes op de softartisans site, staan redelijke goede voorbeeldjes.

zoiets:
code:
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<%@ LANGUAGE="VBSCRIPT" %>

<% 
'--- Module: FORMRESPDB.ASP
'---
'--- Simple file upload form processing.
'--- The result is stored in a database on the server.
'--- Note that it is still necessary to cache the uploaded file in
'--- a file on the server, and then import it into the database.
'--- This two-step process is transparent to the user.
'---
'--- Copyright (c) 1997, 1998, 1999 Software Artisans, Inc.
'--- Mail: info@softartisans.com   http://www.softartisans.com
%>

<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
<TITLE>Simple File Upload To Database Results</TITLE>
</HEAD>
<BODY BGCOLOR="#ffffff">
<%
'---
'--- Instanciate SA-FileUp
'---
Set upl = Server.CreateObject("SoftArtisans.FileUp")
'---
'--- Set the default path to store temporarily cache files. This step is not
'--- strictly necessary, but performance is better if you specify it.
'---
upl.Path = "c:\temp"
%>
<% if upl.IsEmpty Then %>
The file that you uploaded was empty. Most likely, you did not specify a valid
filename to your browser or you left the filename field blank. Please try again.
<% ElseIf upl.ContentDisposition <> "form-data" Then %>
Your upload did not succeed, most likely because your browser
does not support Upload via this mechanism.
<br>
For Internet Explorer Users:
<UL>
<LI>For Windows 95 or Windows NT 4.0:
    <UL>
    <LI><A HREF="http://www.microsoft.com/ie/">Download</A> V3.02 or later of Internet Explorer
    <LI><A HREF="http://www.microsoft.com/ie/download">Download</A> the File Upload Add-on
    <LI>For further information, See Knowledge Base Article <A HREF="http://www.microsoft.com/kb/articles/Q165/2/87.htm">Q165287</A>
    </UL>
<LI>For Windows 3.1, WFW 3.11 (Windows 16-bit), or Windows NT 3.51:
    <UL><A HREF="http://www.microsoft.com/ie/">Download</A> V3.02A or later of Internet Explorer for 16-bit Windows
    </UL>
</UL>
For Netscape Users:
<UL>
<LI><A HREF="http://home.netscape.com">Download</A> a version of Netscape Navigator or Communicator of 2.x or later
</UL>
For users of other browsers:
<UL>
<LI>Your browser must support a standard called RFC 1867. Please check with your browser vendor for
support of this standard.
</UL>
<%Else %>
<P>The file was successfully transmitted by the user.</P>
<% 
'---
'--- Open a connection to the database. Note the CursorType (=2) that *must* 
'--- be used when adding binary (BLOB) type data.
'---
set rsBlob = Server.CreateObject("adodb.recordset")
rsBlob.Open "SimpleBlobTable", "AccessUpload", 2, 3
'--- 
'--- For SQL Server Users, use the following line to open the recordset
'--- Make sure you replace:
'---    <myserver> by your SQL Server name
'---
'--- rsBlob.Open "SimpleBlobTable", "driver={SQL Server};server=<myserver>;uid=sa;pwd=;database=SQLServerUpload", 2, 3

'---
'--- Add new record and update
'---
rsBlob.AddNew
upl.SaveAsBlob rsBlob.Fields("filecol")
rsBlob.Update
rsBlob.Close
Set rsBlob = Nothing 

%>
<P>&nbsp;</P>
<FONT SIZE="-1"><CENTER>
<TABLE WIDTH="80%" BORDER="1" CELLSPACING="2" CELLPADDING="0" HEIGHT="206">
<TR>
<TD COLSPAN="2"><P><CENTER>Information About The Uploaded File</CENTER></TD></TR>
<TR>
<TD WIDTH="30%" HEIGHT="27" ALIGN="RIGHT" VALIGN="TOP">&nbsp;User's filename</TD>
<TD WIDTH="70%"><%=upl.UserFilename%>&nbsp;</TD></TR>
<TR>
<TD WIDTH="30%" HEIGHT="27" ALIGN="RIGHT" VALIGN="TOP">Size in bytes&nbsp;</TD>
<TD WIDTH="70%"><%=upl.TotalBytes%>&nbsp;</TD></TR>
<TR>
<TD WIDTH="30%" HEIGHT="27" ALIGN="RIGHT" VALIGN="TOP">Content Type</TD>
<TD WIDTH="70%"><%=upl.ContentType%>&nbsp;</TD></TR>
<TR>
<TD WIDTH="30%" HEIGHT="27" ALIGN="RIGHT" VALIGN="TOP">Content Disposition</TD>
<TD WIDTH="70%"><%=upl.ContentDisposition%>&nbsp;</TD></TR>
<TR>
<TD WIDTH="30%" HEIGHT="27" ALIGN="RIGHT" VALIGN="TOP">MIME Version</TD>
<TD WIDTH="70%"><%=upl.MimeVersion%>&nbsp;</TD></TR>
<TR>
<TD WIDTH="30%" HEIGHT="27" ALIGN="RIGHT" VALIGN="TOP">Content Transfer Encoding</TD>
<TD WIDTH="70%"><%=upl.ContentTransferEncoding%>&nbsp;</TD></TR>
</TABLE>
</FONT></CENTER>
<% End If %>
</BODY>
</HTML>

Verwijderd

Topicstarter
thnx raptorix, zal ze ff checken en anders kom k hier wel weer klagen :D>:)

Verwijderd

Ja dat klopt :)

Verwijderd

Topicstarter
Op maandag 25 maart 2002 19:12 schreef voetenzalf het volgende:
Ja dat klopt :)
inderdaad
code:
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<%@ LANGUAGE="VBSCRIPT" %>
<% 
'--- Module: FORMRESPDB.ASP
'---
'--- Simple file upload form processing.
'--- The result is stored in a database on the server.
'--- Note that it is still necessary to cache the uploaded file in
'--- a file on the server, and then import it into the database.
'--- This two-step process is transparent to the user.
'---
'--- Copyright (c) 1997, 1998, 1999 Software Artisans, Inc.
'--- Mail: info@softartisans.com   http://www.softartisans.com
%>

<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
<TITLE>Simple File Upload To Database Results</TITLE>
</HEAD>
<BODY BGCOLOR="#ffffff">
<%
'---
'--- Instanciate SA-FileUp
'---
Set upl = Server.CreateObject("SoftArtisans.FileUp")
'---
'--- Set the default path to store temporarily cache files. This step is not
'--- strictly necessary, but performance is better if you specify it.
'---
upl.Path = "g:\activewebroot\00321\w00321988\Admin\Schadeauto's"
%>
<% if upl.IsEmpty Then %>
The file that you uploaded was empty. Most likely, you did not specify a valid
filename to your browser or you left the filename field blank. Please try again.
<% ElseIf upl.ContentDisposition <> "form-data" Then %>
Your upload did not succeed, most likely because your browser
does not support Upload via this mechanism.
<br>
For Internet Explorer Users:
<UL>
<LI>For Windows 95 or Windows NT 4.0:
    <UL>
    <LI><A HREF="http://www.microsoft.com/ie/">Download</A> V3.02 or later of Internet Explorer
    <LI><A HREF="http://www.microsoft.com/ie/download">Download</A> the File Upload Add-on
    <LI>For further information, See Knowledge Base Article <A HREF="http://www.microsoft.com/kb/articles/Q165/2/87.htm">Q165287</A>
    </UL>
<LI>For Windows 3.1, WFW 3.11 (Windows 16-bit), or Windows NT 3.51:
    <UL><A HREF="http://www.microsoft.com/ie/">Download</A> V3.02A or later of Internet Explorer for 16-bit Windows
    </UL>
</UL>
For Netscape Users:
<UL>
<LI><A HREF="http://home.netscape.com">Download</A> a version of Netscape Navigator or Communicator of 2.x or later
</UL>
For users of other browsers:
<UL>
<LI>Your browser must support a standard called RFC 1867. Please check with your browser vendor for
support of this standard.
</UL>
<%Else %>
<P>The file was successfully transmitted by the user.</P>
<% 
'---
'--- Open a connection to the database. Note the CursorType (=2) that *must* 
'--- be used when adding binary (BLOB) type data.
'---
DB_CONNSTRING = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.Mappath("Admin/Database/Database_algemeen.mdb") & ";"
set rsBlob = Server.CreateObject("adodb.recordset")
rsBlob.Open "onderdelen", "memberid", 2, 3  ------> hier zit de fout !!!>:)>:)
'--- 
'--- For SQL Server Users, use the following line to open the recordset
'--- Make sure you replace:
'---
'--- Add new record and update
'---
rsBlob.AddNew
upl.SaveAsBlob rsBlob.Fields("filecol")
rsBlob.Update
rsBlob.Close
Set rsBlob = Nothing 

%>
<P>&nbsp;</P>
<FONT SIZE="-1"><CENTER>
<TABLE WIDTH="80%" BORDER="1" CELLSPACING="2" CELLPADDING="0" HEIGHT="206">
<TR>
<TD COLSPAN="2"><P><CENTER>Information About The Uploaded File</CENTER></TD></TR>
<TR>
<TD WIDTH="30%" HEIGHT="27" ALIGN="RIGHT" VALIGN="TOP">&nbsp;User's filename</TD>
<TD WIDTH="70%"><%=upl.UserFilename%>&nbsp;</TD></TR>
<TR>
<TD WIDTH="30%" HEIGHT="27" ALIGN="RIGHT" VALIGN="TOP">Size in bytes&nbsp;</TD>
<TD WIDTH="70%"><%=upl.TotalBytes%>&nbsp;</TD></TR>
<TR>
<TD WIDTH="30%" HEIGHT="27" ALIGN="RIGHT" VALIGN="TOP">Content Type</TD>
<TD WIDTH="70%"><%=upl.ContentType%>&nbsp;</TD></TR>
<TR>
<TD WIDTH="30%" HEIGHT="27" ALIGN="RIGHT" VALIGN="TOP">Content Disposition</TD>
<TD WIDTH="70%"><%=upl.ContentDisposition%>&nbsp;</TD></TR>
<TR>
<TD WIDTH="30%" HEIGHT="27" ALIGN="RIGHT" VALIGN="TOP">MIME Version</TD>
<TD WIDTH="70%"><%=upl.MimeVersion%>&nbsp;</TD></TR>
<TR>
<TD WIDTH="30%" HEIGHT="27" ALIGN="RIGHT" VALIGN="TOP">Content Transfer Encoding</TD>
<TD WIDTH="70%"><%=upl.ContentTransferEncoding%>&nbsp;</TD></TR>
</TABLE>
</FONT></CENTER>
<% End If %>
</BODY>
</HTML>

heb het zo aangepast maar krijg de volgende error:

The file was successfully transmitted by the user.

Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
/test-upload.asp, line 69

dus hlp plz

Verwijderd

Hij zegt dat ie je database niet kan vinden. Kijk het path of de DSN string maar es na

Verwijderd

Topicstarter
deze kloppen beide ??? |:(

Verwijderd

Topicstarter
raptorix, je had het over voorbeeldjes op de softartisans site... maar dat zijn niet de goeje voor me dus wie helpt me verder of geeft me de goede script ????:'(:'(:'( krijgt zo niet klaar ;)

Verwijderd

Op dinsdag 26 maart 2002 21:39 schreef franchofsteenge het volgende:
raptorix, je had het over voorbeeldjes op de softartisans site... maar dat zijn niet de goeje voor me dus wie helpt me verder of geeft me de goede script ????:'(:'(:'( krijgt zo niet klaar ;)
Wat moet er gefixed worden ?

edit:

Ik ben al vast de laatste code aan 't debuggen ;)

Verwijderd

Topicstarter
tnhx :D

de bedoel is dat wanneer k bv een foto upload dat de locatie opgeslagen wordt in een database (GEEN SQL)

mn verbinding:
code:
1
DB_CONNSTRING = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.Mappath("Admin/Database/Database_algemeen.mdb") & ";"

anders add me ff op msn:
msn@hofsteenge.tk

Verwijderd

DB_CONNSTRING = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.Mappath("Admin/Database/Database_algemeen.mdb") & ";"
Deze connectiestring lijkt goed. Het enige dat ik niet kan beoordelen is of het pad goed is. Probeer je database eens in de root te zetten, en probeer 'm dan te benaderen met:
code:
1
2
DB_CONNSTRING = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & _
Server.Mappath("Database_algemeen.mdb") & ";"

Overigens is de laatste punt-komma niet nodig, laat die eens weg...
Pagina: 1