Welcome to Abdul Malik Ikhsan's Blog

Asp konek ke SQL Server

Posted in Tutorial ASP by samsonasik on October 2, 2007

Saya menggunakan Baby webserver sebagai webservernya :
Misalkan kita punya database bernama ikhsan, userid ke sql server = sa, dan password ” (kosong), terus kita punya table buku (kode_buku, nama_buku)
berikut source code file configurasinya :

Code:
<%
‘conf.asp
set conn=Server.CreateObject(“ADODB.Connection”)
cstring=”driver={SQL Server};server=”&localhost&”;uid=sa;pwd=;database=”&ikhsan
conn.Open cstringset rs=Server.CreateObject(“ADODB.recordset”)
%>

——————
Tampil.asp
——————
<!–#include file=”conf.asp”–>
<%
sql=”SELECT * from ikhsan.dbo.buku”
rs.Open sql, conn
%>
<table border=1>
<tr>
<td>No.</td>
<td>Kode Buku</td>
<td>Nama Buku</td>
</tr>
<%
Dim no
no=0
while NOT rs.EOF
no = no + 1
%>
<tr>
<td><%=no%></td>
<td><% Response.Write(rs(“kode_buku”)) %></td>
<td><% Response.Write(rs(“nama_buku”)) %></td>
</tr>
<%
rs.MoveNext
Wend
%>

One Response

Subscribe to comments with RSS.

  1. djie said, on March 20, 2012 at 2:40 pm

    wah ini awal pelajaran yang bagus… thanks


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: