|
We installed SQLServer 7 on our CC2 server. We created a
database called "mydbase" and inserted a table called "mytable"
with an Image column called "myimage". Finally we created a user
"myuser" with password "password" and read/write access to the
database.
In the code below we first check to see that an image file has
been uploaded. If it has we connect to the database and then open a
RecordSet. We add a new record and put the field data from the
upload into the "myimage" column. Finally we update the RecordSet
and close our connection.
<% @Language="VBScript" %>
<%
Set theForm = Server.CreateObject("ABCUpload4.XForm")
Set theField = theForm("filefield")(1)
If theField.FileExists and theField.ImageType <> 0 Then
Set cn = Server.CreateObject("ADODB.Connection")
theConn = "Provider=SQLOLEDB;Data Source=CC2;Initial
Catalog=mydbase;User Id=myuser;Password=password"
cn.Open theConn
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "mytable", cn, 1, 3
rs.AddNew
rs("myimage").Value = theField.Data
rs.Update
rs.Close
cn.Close
End If
%>
<html>
<body>
File uploaded...
</body>
</html>
|