Selasa, 22 Maret 2011

pelajaran saya

/*
create database computer
on
(name=computer_dat,filename='D:\adly_sql\ujian\computerdat.mdf',
size=10,
maxsize=50,
filegrowth=5)
log on
(name=computer_log,filename='D:\adly_sql\ujian\computerlog.ldf',
size=10,
maxsize=50,
filegrowth=5)
*/
/*
create table customer
(ID_customer varchar(3)Not null primary key,
Nama_customer varchar(15),
Alamat varchar(20),
telp varchar(12),
contact_person varchar(20))
*/
select * from customer
--insert into customer
--values('C01','Toko H-Tech','JL.Merdeka 123','0761707575','ibu lily')
--values('C02','Toko SweetCom','JL.Garuda 25','0761755565','Bapak Harun')
--values('C03','Toko StarCom','JL.Subrantas 254','0761777575','Bapak Zakaria')
--values('C04','Toko SunCom','JL.penghulu 345','0761858265','ibu Melly')
/*
create table peroduk
(Kode_produk varchar(6)Not null primary key,
Nama_produk varchar(20),
Merk varchar(10),
Harga numeric)
*/
select * from peroduk
--insert into peroduk
--values('MUG25','Mouse','Genius','25000')
--values('MWL85','Mouse Wireless','Logic','85000')
--values('UK8130','Flash Memory 8G','Kingston','135000')
--values('MS4100','Memory SD 4G','Sony','100000')
/*
create table Transaksi
(tanggal_Transaksi datetime,
ID_customer varchar(3),
Kode_produk varchar(6),
jumlah numeric,
potongan numeric,
Hutang numeric)
*/
select * from Transaksi
--insert into Transaksi
--values('2011/01/04','C01','UK8130','24','0','0')
--values('2011/1/04','C01','MWl85','36','100000','600000')
--values('2011/1/06','C03','MS4100','20','0','0')
--values('2011/1/06','C04','UK8130','40','150000','1000000')
--delete Transaksi where ID_customer= 'C01'

--update Transaksi set jumlah='38',potongan='125000' Where ID_customer='C01' and Kode_produk='MWl85'
--select * from  customer,produk,Transaksi
select tanggal_Transaksi,Nama_produk,Merk,jumlah from peroduk inner join Transaksi
on peroduk.kode_produk=Transaksi.Kode_produk
select tanggal_Transaksi,Nama_customer,Hutang from Transaksi inner join customer
on Transaksi.ID_customer=customer.ID_customer



select tanggal_Transaksi,Nama_customer,Nama_produk,Merk,jumlah,potongan,Hutang from Transaksi  inner join produk
on Transaksi.kode_produk=Produk.Kode_produk
inner join customer
on Transaksi.ID_customer=customer.ID_customer


asp
form
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ASP - Form Post</title>
</head>

<body>
    <div class="box">
        <form action="form.asp" method="post">
            <label>Form - POST</label>
            <label for="nama">Nama : <input type="text" name="nama" size="20" maxlength="10" /></label>
            <input type="submit" name="kirim" value="Kirimkan" size="20" />
        </form>
        <form action="form.asp" method="get">
            <label>Form - GET</label>
            <label for="nama">Nama : <input type="text" name="nama" size="20" maxlength="10" /></label>
            <input type="submit" name="kirim" value="Kirimkan" size="20" />
        </form>
    </div>
    <div class="hasil">
        <% Response.Write("<h3>Nama (POST) = " & Request.Form("nama") & "</h3>") %>
        <% Response.Write("<h3>Nama (GET) = " & Request.QueryString("nama") & "</h3>") %>
    </div>
</body>
</html>

koneksi


<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>

<%
    ' Deklarasikan variable yg akan digunakan
    Dim myKoneksiString
    Dim myKoneksi
   
    ' Tentukan Connection String
    myKoneksiString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\My Labs\Web\ASP Classic\LP3I\database\Database1.accdb"
   
    ' Buat objek koneksi
    Set myKoneksi = Server.CreateObject("ADODB.Connection")
   
    ' Buka koneksi ke database
    myKoneksi.Open myKoneksiString
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Latihan Koneksi Database</title>
</head>

<body>

<%
    ' Lihat status koneksi
    If myKoneksi.State = 1 Then
        Response.Write("Database telah terhubung.")
    Else
        Response.Write("Database belum terhubung.")
    End If
%>

</body>
</html>

<%
    ' Tutup Koneksi ke database
    myKoneksi.Close
   
    ' Kosongkan variable
    Set myKoneksi = Nothing
%>


web

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <defaultDocument>
            <files>
                <add value="index.asp" />
            </files>
        </defaultDocument>
    </system.webServer>
</configuration>
cookies
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>

<%
' Contoh Cookies
' ==============
Dim str

if Request.Cookies("co1") <> "" Then
    str = Request.Cookies("co1")
end if

if Request.Form("teks") <> "" Then
    Response.Cookies("co1") = Request.Form("teks")
end if

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<h1> Teks : <% Response.Write(str) %></h1>
<form action="" method="post">
    <input type="text" name="teks" />
    <input type="submit" name="go" />
</form>
</body>
</html>
judul

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Judul</title>
</head>

<body>
</body>
</html>

recordset

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>

<%
    ' Deklarasikan variable yg akan digunakan
    Dim myKoneksiString
    Dim myKoneksi
    Dim myQuery
    Dim myRecordset
    Dim myData
   
    ' Tentukan Connection String
    myKoneksiString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\My Labs\Web\ASP Classic\LP3I\database\Database2.mdb" ' Acces 2003
   
    ' Buat objek koneksi
    Set myKoneksi = Server.CreateObject("ADODB.Connection")
    Set myRecordset = Server.CreateObject("ADODB.Recordset")
   
    ' Buka koneksi ke database
    myKoneksi.Open myKoneksiString
   
    ' Buat konstanta untuk recordset
    Const adOpenForwardOnly = 0
    Const adLockOptimistic = 3
   
    ' Buat query ke database
    myQuery = "SELECT * FROM Mahasiswa"
   
    ' Query ke database
    myRecordset.Open myQuery, myKoneksi, adOpenForwardOnly, adLockOptimistic
   
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Latihan Mengambil Data Recordset</title>
</head>

<body>

<%   
    ' Tampilkan data
    While Not myRecordset.EOF
        Response.Write("No : " & myRecordset.Fields("No").Value & " :: ")
        Response.Write("Nama : " & myRecordset.Fields("Nama").Value & " :: ")
        Response.Write("Alamat : " & myRecordset.Fields("Alamat").Value & "<br />")
        myRecordset.MoveNext
    Wend
   
%>

</body>
</html>

<%
    ' Tutup recordset
    myRecordset.Close
   
    ' Kosongkan recordset
    Set myRecordset = Nothing
   
    ' Tutup Koneksi ke database
    myKoneksi.Close
   
    ' Kosongkan variable
    Set myKoneksi = Nothing
%>
mmhtpdb

<%@LANGUAGE="VBScript"%>
<%
currentSessionCodePage = Session.CodePage
svr = Request.ServerVariables("SERVER_SOFTWARE")
ix = Instr(svr, "/")
verStr = right(svr, len(svr)-ix)
Dim verEnd
verEnd = len(verStr)
For i = 1 To len(verStr)
  char = Mid(verStr, i, 1)
  if char >= "0" And char <= "9" Then
    verEnd = i
  Else
    Exit For
  End if
Next
verStr = Left(verStr, verEnd)
ver = CInt(verStr)
if ver > 4 then
    Session.CodePage=65001
end if
%>
<HTML>
<!--#include file ="MMHTTPDB.js"-->
<%
On Error Resume Next
Set oConn = CreateMMConnection(Request("ConnectionString"),Request("UserName"),Request("Password"),Request("Timeout"))
Dim opCode
opCode = CStr(Request("opCode"))
if (Len(opCode) AND (opCode <> "undefined")) then
    if (opCode = "GetODBCDSNs") then
        Response.Write(oConn.GetODBCDSNs())
    elseif (opCode = "GetTables") then
        oConn.Open()
        Response.Write(oConn.GetTables(Request("Schema"),Request("Catalog")))
    elseif (opCode = "GetViews") then
        oConn.Open()
        Response.Write(oConn.GetViews(Request("Schema"),Request("Catalog")))
    elseif (opCode = "GetProcedures") then
        oConn.Open()
        Response.Write(oConn.GetProcedures(Request("Schema"),Request("Catalog")))
    elseif (opCode = "GetColsOfTable") then
        oConn.Open()
        Response.Write(oConn.GetColumnsOfTable(Request("TableName"),Request("Schema"),Request("Catalog")))
    elseif (opCode = "GetParametersOfProcedure") then
        oConn.Open()
        Response.Write(MarshallRecordsetIntoHTML(oConn.GetParametersOfProcedure(Request("ProcName"),Request("Schema"),Request("Catalog"))))
    elseif (opCode = "ExecuteSQL") then
        oConn.Open()
        Response.Write(oConn.ExecuteSQL(Request("SQL"),Request("MaxRows")))
    elseif (opCode = "ExecuteSP") then
        oConn.Open()
        Response.Write(oConn.ExecuteSP(Request("ExecProcName"),0,Request("ExecProcParameters")))
    elseif (opCode = "ReturnsResultset") then
        oConn.Open()
        Response.Write(oConn.ReturnsResultSet(Request("RRProcName"),Request("Schema"),Request("Catalog")))
    elseif (opCode = "SupportsProcedure") then
        oConn.Open()
        Response.Write(oConn.SupportsProcedure())
    elseif (opCode =  "GetProviderTypes") then
        oConn.Open()
        Response.Write(oConn.GetProviderTypes())
    elseif (opCode = "IsOpen") then
        oConn.Open()
        Response.Write(oConn.TestOpen())
    elseif (opCode = "GetKeysOfTable") then
        oConn.Open()
        Response.Write(oConn.GetPrimaryKeysOfTable(Request("TableName"),Request("Schema"),Request("Catalog")))
    end if

    if Err then
        Response.Write(oConn.HandleExceptions())
    end if

    oConn.Close()
end if

Session.CodePage = currentSessionCodePage

%>
</HTML>

Tidak ada komentar:

Posting Komentar