69 lines
1.8 KiB
Plaintext
69 lines
1.8 KiB
Plaintext
|
<%@ Language=VBScript %>
|
||
|
<%
|
||
|
Option Explicit
|
||
|
Response.Expires = 0
|
||
|
' *****************************
|
||
|
' Variable Declarations
|
||
|
' *****************************
|
||
|
' Strings
|
||
|
Dim SQL
|
||
|
' Integers & Numerics
|
||
|
' Objects
|
||
|
Dim cn, rs
|
||
|
' Other
|
||
|
' *****************************
|
||
|
' Initialize Variables
|
||
|
' *****************************
|
||
|
%>
|
||
|
<HTML>
|
||
|
<HEAD>
|
||
|
<!-- #INCLUDE Virtual="/include/ForceFrame.htm" -->
|
||
|
<TITLE>Insert using SPT (SQL pass-thru)</TITLE></HEAD>
|
||
|
<BODY>
|
||
|
<BASEFont Face="Verdana,Arial">
|
||
|
<%
|
||
|
If Request.Form("TextCol") = "" Then
|
||
|
%>
|
||
|
<FORM Action=SQLInsert.asp Method=Post>
|
||
|
<TEXTAREA Rows=10 Cols=45 Name=TextCol>This example uses SQL Pass-thru To insert
|
||
|
a record into a database. This method allows us To insert into BLOB fields such As
|
||
|
SQL Server Text fields, FoxPro Memo fields, Or other fields > 255 characters.
|
||
|
This has an embedded Single quote(') To show how these can be handled With
|
||
|
an SQL insert.</TEXTAREA><P>
|
||
|
<Input Type=Submit Name=btnSubmit Value="Submit">
|
||
|
</FORM>
|
||
|
<%
|
||
|
Else
|
||
|
Set cn = Server.CreateObject("ADODB.Connection")
|
||
|
cn.Open Application("guestDSN")
|
||
|
SQL = "INSERT INTO pubs..paulen (TextCol) "
|
||
|
SQL = SQL & " VALUES ('" & padQuotes(Request("TextCol")) & "')"
|
||
|
cn.Execute SQL
|
||
|
Response.Write "<B>Inserted:</B><BR>" & Request("TextCol")
|
||
|
End If
|
||
|
%>
|
||
|
<P>
|
||
|
<%
|
||
|
Function padQuotes( instring )
|
||
|
REM This Function pads an extra Single q
|
||
|
' uote in strings containing quotes for
|
||
|
REM proper SQL searching.
|
||
|
Dim bodybuild
|
||
|
Dim bodystring
|
||
|
Dim Length
|
||
|
Dim i
|
||
|
bodybuild = ""
|
||
|
bodystring = instring
|
||
|
Length = Len(bodystring)
|
||
|
For I = 1 To length
|
||
|
bodybuild = bodybuild & Mid(bodystring, I, 1)
|
||
|
If Mid(bodystring, I, 1) = Chr(39) Then
|
||
|
bodybuild = bodybuild & Mid(bodystring, I, 1)
|
||
|
End If
|
||
|
Next
|
||
|
bodystring = bodybuild
|
||
|
padQuotes = bodystring
|
||
|
End Function
|
||
|
%>
|
||
|
</BODY>
|
||
|
</HTML>
|