ASP 프로그램 팁
간단하면서도 프로그램에 도움이 되는 , 알아두면 아주 유용한 기능이나 함수들을 모아두고 있습니다.
[1] 마지막으로 추가된 레코드의 autonumber 받아오기 방법 3 (가장 좋은 방법) 가장 확실한 방법입니다.

Dim loConn, lsSQL, loRs
Set loConn = CreateObject("ADODB.Connection")

' Open a connection to the database
loConn.Open("DSN=myDSN;UID=something;PWD=Something;")

' Insert a new record into the table
lsSQL = "SET NOCOUNT ON;" &_
"INSERT INTO tMembers (MemberName) VALUES ('Manohar');" &_
"SELECT @@IDENTITY AS NewID;"

[2] 마지막으로 추가된 레코드의 autonumber 받아오기 방법2 Dim loConn, lsSQL, loRs
Set loConn = CreateObject("ADODB.Connection")

' Open a connection to the database
loConn.Open("DSN=myDSN;UID=something;PWD=Something;")

' Insert a new record into the table
lsSQL = "INSERT INTO tMembers (MemberName) VALUES ('Manohar');" &_
"SELECT @@IDENTITY AS NewID;"

' Execute the SQL statement
Set loRs = loConn.Execu .....
[3] 마지막으로 추가된 레코드의 autonumber 받아오기 방법1 Dim loConn, lsSQL, loRs
Set loConn = CreateObject("ADODB.Connection")
' Open a connection to the database
loConn.Open("DSN=myDSN;UID=something;PWD=Something;")

' Insert a new record into the table
lsSQL = "INSERT INTO tMembers (MemberName) VALUES ('Manohar')"

' Execute the SQL statement
loConn.Execute(lsSQL)

' Get the @@IDENTITY. The key statement is .....
[4] to get autoNumber last created from table set rs1 = server.CreateObject ("ADODB.Recordset")
sqlIns = "select top 1 * from tbl_artnames "
rs1.Open sqlIns, dbCon, 3, 3
rs1.addnew
rs1("baseArt") = baseArt
rs1.update
rs1.close

sql = "Select @@Identity"
rs1.Open sql, dbCon, 3, 3
tIdx = rs1(0)

rs1.close
sql .....
[5] vb.net raw data print Imports System.Runtime.InteropServices
Public Class LinePrinter
#Region " Shared Win32 API Calls "
Public Structure DOCINFO
<MarshalAs(UnmanagedType.LPWStr)> Public pDocName As String
<MarshalAs(UnmanagedType.LPWStr)> Public pOutputFile As String
<MarshalAs(UnmanagedType.LPWStr)> Public pDataType As String
End Structure
<DllImport("winspool.dr .....
[6] 시리얼 포트를 통한 통신(Serial port chat) vb.net c#.net //C# version


using System;
using System.IO.Ports;
using System.Threading;

public class PortChat
{
static bool _continue;
static SerialPort _serialPort;

public static void Main()
{
string name;
string message;
StringComparer stringComparer = StringComparer.OrdinalIgnoreCase;
Threa .....
[7] CSS 화일을 자동으로 생성해주는 방법 You don't have to use the .css extension for an included style sheet. You
can acutally use a .asp extension and intersperse asp and css much the same
way you would if you had html interspersed within an asp page. You just have
to set the content type of the .asp css file to text/css.

An example of what's in an .asp file linked to instead of a .css file is...
THE HTML
- .....
[8] How do I send e-mail with CDO? - no schema URL/namespace <!--
METADATA
TYPE="typelib"
UUID="CD000000-8B95-11D1-82DB-00C04FB1625D"
NAME="CDO for Windows 2000 Library"
-->
<%
Set cdoConfig = CreateObject("CDO.Configuration")

With cdoConfig.Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "<enter_mail.server_here>"
.....
[9] How do I send e-mail with CDO? <%
sch = "http://schemas.microsoft.com/cdo/configuration/"

Set cdoConfig = CreateObject("CDO.Configuration")

With cdoConfig.Fields
.Item(sch & "sendusing") = 2 ' cdoSendUsingPort
.Item(sch & "smtpserver") = "<enter_mail.server_here>"
.update
End With

Set cdoMessage = CreateObject("CDO.Message" .....
[10] Base 64 Encode / Decode
'**************************************
' Name: Base 64 Encode / Decode
' Description:Base 64 encodeing is used
' to convert binary files to a "safe" form
' at for transporting files through smtp (
' email) and other protocols. It is also u
' sed for basic authentication. With this
' code, you can decode the current .....
[11] Recurse Through All SubFolders Of Any Given Path Sub Recurse(Path)

Dim fso, Root, WindowsFolder, Files, _
Folders, File, i, FoldersArray(100)

Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set Root = fso.getfolder(Path)
Set Files = Root.Files
Set Folders = Root.SubFolders
For Each File In Files
'''''''''''''''''''''''''''''
.....
[12] The CASE Statement <% SELECT CASE Request.Form("Category") %>

<% CASE "Home" %>

<% Response.Redirect "index.html" %>

<% CASE "About Me" %>

<% Response.Redirect "about_me.html" %>

<% CASE "About HTML" %>

<% Response.Redirect "about_html.html" %>

<% CASE "About ASP" %>

<% Response.Redirect "about_asp.html" .....
[13] The IF .. THEN Statement IF strName = "N/A" THEN

strName = "Not Available"

END IF

what kind of comparisons can I do?

There are quite a few comparisons that you can make. Here they are along with the data types that they apply to:

= Equal to. You can use this to compare any data type.
< Less than. You can use this to compare any numeric data type. (You can also .....
[14] record the IP address of all visitor to our page to a file named "mylog.txt" <%
VisitorsIP=Request.ServerVariables ("REMOTE_ADDR")
Set fs = CreateObject("Scripting.FileSystemObject")

Set wfile = fs.OpenTextFile("c:\Mydir\mylog.txt", 8,false,0)
wfile.WriteLine (VisitorsIP)

wfile.close
Set wfile=nothing
Set fs=nothing

response.write("IP registered")
%>


The IP address is requested in line 2 (check Fun .....
[15] Create and Write a text file <%
thetext="Write this text in the file"
Set fs = CreateObject("Scripting.FileSystemObject")

Set wfile = fs.CreateTextFile("c:\Mydir\myfile.txt", True)
wfile.Write (thetext)

wfile.close
Set wfile=nothing
Set fs=nothing

response.write("Text created")
%>

The method used in line 6 is "CreateTextFile"; it is necessary to indicate t .....
[16] a file with a number in line 1 and a second number in line 2. <%
Set fs = CreateObject("Scripting.FileSystemObject")
Set wfile = fs.OpenTextFile("c:\Mydir\myfile.txt")

number1 = Clng(wfile.ReadLine)
number2= Clng(wfile.ReadLine)

number1and2 = number1 + number2
response.write (number1and2)

wfile.close
Set wfile=nothing
Set fs=nothing

%>

In this example we have saved the content o .....
[17] read all lines in the file, and the response page will include the content of each line with its lin <%
Set fs = CreateObject("Scripting.FileSystemObject")
Set wfile = fs.OpenTextFile("c:\Mydir\myfile.txt")

counter=0
do while not wfile.AtEndOfStream
counter=counter+1
singleline=wfile.readline
response.write (counter & singleline & "<br>")
loop

wfile.close
Set wfile=nothing
Set fs=nothing

%>


define the .....
[18] open read information in each line <%
Set fs = CreateObject("Scripting.FileSystemObject")
Set wfile = fs.OpenTextFile("c:\Mydir\myfile.txt")
firstname = wfile.ReadLine
lastname = wfile.ReadLine
theage = wfile.ReadLine

wfile.close
Set wfile=nothing
Set fs=nothing

%>

Your first name is <% =firstname %><BR>
Your last name is <% =firstname %><BR>
Your .....
[19] open a text file <%
Set fs = CreateObject("Scripting.FileSystemObject")
Set wfile = fs.OpenTextFile("c:\Mydir\myfile.txt")
filecontent = wfile.ReadAll

wfile.close
Set wfile=nothing
Set fs=nothing

response.write(filecontent)
%>

Line 2 will create the appropriate environment which allows to perform the operations involving files in the server. We have defi .....
[20] change iis for aspnet c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis.exe -i
    [1] [2] [3] [4] [5]    
Javascript Source List :