Jag är inte bra på ASP alls....men det är så här att jag har en funktion som stönarsig med att ansluta till datbasen så här... Rätt connectionsträngar bör se ut som följer: Om du har vanligt lösenord på databasen ska strängen se ut såhär: ne det funkar inte... Kanske denna sträng ska fungera bättre? Du har ju fortfarande inte skapat ett connection-objekt!Lösenord...
-------------------
Dim connStr
connStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("../databas/users.mdb")
Dim rs
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "Files", connStr, 2, 2
-------------------
någon som vet hur man kan lägga till lösenordet?
just nu säger han bara
Microsoft JET Database Engine fel '80040e4d'
Ogiltigt lösenord.
/nht2.asp, rad 136
(136 = rs.Open "Files", connStr, 2, 2)Sv: Lösenord...
' Standard
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\somepath\myDb.mdb;" & _
"User Id=admin;" & _
"Password=;"
' Om du använder en systemdatabas:
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\somepath\mydb.mdb;" & _
"Jet OLEDB:System Database=MySystem.mdw;", _
"admin", ""
' Glöm inte att konvertera både MDB och MDW till version 4.0 format
' när du använder OLE DB 4.0 providern.
' Om MDB har ett lösenord:
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\somepath\mydb.mdb;" & _
"Jet OLEDB:Database Password=MyDbPassword;", _
"admin", ""
' Om MDB är placerad på en delad disk på nätet
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=\\myServer\myShare\myPath\myDb.mdb;
' Om du vill öppna databasen explusivt:
con.Mode = adModeShareExclusive
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\somepath\myDb.mdb;" & _
"User Id=admin;" & _
"Password=;"
Se vidare:
http://www.pellesoft.nu/login/articles/other/connectionstrings.asp#OLE%20DB%20för%20Microsoft%20Jet:Sv: Lösenord...
connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("../databas/users.mdb") & ";Jet OLEDB:Database Password=xxxx"
Nu ser jag att du försöker använda din connectionstring som ett connectionobjekt, såhär borde det vara istället:
Dim connStr
connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("../databas/users.mdb") & ";Jet OLEDB:Database Password=xxxx"
Dim conn
Set conn = Server.CreateObject("ADODB.Connection")
conn.open connStr
Dim rs
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "Files", conn, 2, 2
/JohanSv: Lösenord...
inget av de där exemplen
han säger bara
Microsoft JET Database Engine fel '80040e14'
Ogiltigt SQL-uttryck. 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT' eller 'UPDATE' förväntades.
/nht2.asp, rad 134
----
exempel jag jobbaruitfrån är som följer:
<!--#include file="/Loader.asp"-->
<%
Response.Buffer = True
' load object
Dim load
Set load = new Loader
' calling initialize method
load.initialize
' File binary data
Dim fileData
fileData = load.getFileData("file")
' File name
Dim fileName
fileName = LCase(load.getFileName("file"))
' File path
Dim filePath
filePath = load.getFilePath("file")
' File path complete
Dim filePathComplete
filePathComplete = load.getFilePathComplete("file")
' File size
Dim fileSize
fileSize = load.getFileSize("file")
' File size translated
Dim fileSizeTranslated
fileSizeTranslated = load.getFileSizeTranslated("file")
' Content Type
Dim contentType
contentType = load.getContentType("file")
' No. of Form elements
Dim countElements
countElements = load.Count
' Value of text input field "fname"
Dim fnameInput
fnameInput = load.getValue("fname")
' Value of text input field "lname"
Dim lnameInput
lnameInput = load.getValue("lname")
' Value of text input field "profession"
Dim profession
profession = load.getValue("profession")
' destroying load object
Set load = Nothing
%>
<html>
<head>
<title>Inserts Images into Database</title>
<style>
body, input, td { font-family:verdana,arial; font-size:10pt; }
</style>
</head>
<body>
<p align="center">
<table width="700" border="1" align="center">
<tr>
<td>File Name</td><td><%= fileName %></td>
</tr><tr>
<td>File Path</td><td><%= filePath %></td>
</tr><tr>
<td>File Path Complete</td><td><%= filePathComplete %></td>
</tr><tr>
<td>File Size</td><td><%= fileSize %></td>
</tr><tr>
<td>File Size Translated</td><td><%= fileSizeTranslated %></td>
</tr><tr>
<td>Content Type</td><td><%= contentType %></td>
</tr><tr>
<td>No. of Form Elements</td><td><%= countElements %></td>
</tr><tr>
<td>First Name</td><td><%= fnameInput %></td>
</tr><tr>
<td>Last Name</td><td><%= lnameInput %></td>
</tr>
<tr>
<td>Profession</td><td><%= profession %></td>
</tr>
</table><br><br>
<p style="padding-left:220;">
<%= fileName %> data received ...<br>
<%
' Checking to make sure if file was uploaded
If fileSize > 0 Then
' Connection string
Dim connStr
connStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("FileDB.mdb")
' Recordset object
Dim rs
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "Files", connStr, 2, 2
' Adding data
rs.AddNew
rs("File Name") = fileName
rs("File Size") = fileSize
rs("File Data").AppendChunk fileData
rs("Content Type") = contentType
rs("First Name") = fnameInput
rs("Last Name") = lnameInput
rs("Profession") = profession
rs.Update
rs.Close
Set rs = Nothing
Response.Write "<font color=""green"">File was successfully uploaded...</font>"
Else
Response.Write "<font color=""brown"">No file was selected for uploading...</font>"
End If
If Err.number <> 0 Then
Response.Write "<br><font color=""red"">Something went wrong...</font>"
End If
%>
</p>
<br>
<table border="0" align="center">
<tr>
<form method="POST" enctype="multipart/form-data" action="Insert.asp">
<td>First Name :</td><td>
<input type="text" name="fname" size="40" value="Faisal"></td></tr>
<td>Last Name :</td><td>
<input type="text" name="lname" size="40" value="Khan"></td></tr>
<td>Profession :</td><td>
<input type="text" name="profession" size="40" value="Developer"></td></tr>
<td>File :</td><td>
<input type="file" name="file" size="40"></td></tr>
<td> </td><td>
<input type="submit" value="Submit"></td></tr>
</form>
</tr>
</table>
</body>
</html>
--------------------
men skillnaden är att databasen har ett lösenordSv: Lösenord...
connStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("FileDB.mdb") & ";pwd=" & strPassword & ";" 'ditt lösenordSv: Lösenord...
<code>
<!--#include file="/Loader.asp"-->
<%
Response.Buffer = True
' load object
Dim load
Set load = new Loader
' calling initialize method
load.initialize
' File binary data
Dim fileData
fileData = load.getFileData("file")
' File name
Dim fileName
fileName = LCase(load.getFileName("file"))
' File path
Dim filePath
filePath = load.getFilePath("file")
' File path complete
Dim filePathComplete
filePathComplete = load.getFilePathComplete("file")
' File size
Dim fileSize
fileSize = load.getFileSize("file")
' File size translated
Dim fileSizeTranslated
fileSizeTranslated = load.getFileSizeTranslated("file")
' Content Type
Dim contentType
contentType = load.getContentType("file")
' No. of Form elements
Dim countElements
countElements = load.Count
' Value of text input field "fname"
Dim fnameInput
fnameInput = load.getValue("fname")
' Value of text input field "lname"
Dim lnameInput
lnameInput = load.getValue("lname")
' Value of text input field "profession"
Dim profession
profession = load.getValue("profession")
' destroying load object
Set load = Nothing
%>
<html>
<head>
<title>Inserts Images into Database</title>
<style>
body, input, td { font-family:verdana,arial; font-size:10pt; }
</style>
</head>
<body>
<p align="center">
<table width="700" border="1" align="center">
<tr>
<td>File Name</td><td><%= fileName %></td>
</tr><tr>
<td>File Path</td><td><%= filePath %></td>
</tr><tr>
<td>File Path Complete</td><td><%= filePathComplete %></td>
</tr><tr>
<td>File Size</td><td><%= fileSize %></td>
</tr><tr>
<td>File Size Translated</td><td><%= fileSizeTranslated %></td>
</tr><tr>
<td>Content Type</td><td><%= contentType %></td>
</tr><tr>
<td>No. of Form Elements</td><td><%= countElements %></td>
</tr><tr>
<td>First Name</td><td><%= fnameInput %></td>
</tr><tr>
<td>Last Name</td><td><%= lnameInput %></td>
</tr>
<tr>
<td>Profession</td><td><%= profession %></td>
</tr>
</table><br><br>
<p style="padding-left:220;">
<%= fileName %> data received ...<br>
<%
' Checking to make sure if file was uploaded
If fileSize > 0 Then
' Connection string
Dim connStr
connStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("FileDB.mdb")
' Recordset object
Dim rs, conn
Set rs = Server.CreateObject("ADODB.Recordset")
Set conn = Server.CreateObject("ADODB.Connection")
conn.open connStr
rs.Open "Files", conn, 2, 2
' Adding data
rs.AddNew
rs("File Name") = fileName
rs("File Size") = fileSize
rs("File Data").AppendChunk fileData
rs("Content Type") = contentType
rs("First Name") = fnameInput
rs("Last Name") = lnameInput
rs("Profession") = profession
rs.Update
rs.Close
Set rs = Nothing
Response.Write "<font color=""green"">File was successfully uploaded...</font>"
Else
Response.Write "<font color=""brown"">No file was selected for uploading...</font>"
End If
If Err.number <> 0 Then
Response.Write "<br><font color=""red"">Something went wrong...</font>"
End If
%>
</p>
<br>
<table border="0" align="center">
<tr>
<form method="POST" enctype="multipart/form-data" action="Insert.asp">
<td>First Name :</td><td>
<input type="text" name="fname" size="40" value="Faisal"></td></tr>
<td>Last Name :</td><td>
<input type="text" name="lname" size="40" value="Khan"></td></tr>
<td>Profession :</td><td>
<input type="text" name="profession" size="40" value="Developer"></td></tr>
<td>File :</td><td>
<input type="file" name="file" size="40"></td></tr>
<td> </td><td>
<input type="submit" value="Submit"></td></tr>
</form>
</tr>
</table>
</body>
</html>
</code>
/Johan