Asp ile excel sorgulmasında bir asp ve bir excel dosyası ile http://pc-destek.info/asp_excel/excel.asp adresten tckimlik e göre sorgulayabiliyoruz. Bu sorguyu aynı zamanda ada soyada göre yapabilmeyi nasıl yapabiliriz.
veri.xls dosyası
SIRANO
SOYADI
ADI
ALDIGICEZA
TAKIM_ADI
TCNO
1
TAŞ
AHMET
1 MAÇ
KADIKÖY
44221111333
2
KAYA
AHMET
2 MAÇ
KADIKÖY
44221111333
3
TOPRAK
HASAN
2 MAÇ
ERENKÖY
10000000000
excel.asp kodları
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1254"%>
<!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=iso-8859-9>
<META http-equiv=content-type content=text/html;charset=windows-1254>
<META http-equiv=content-type content=text/html;charset=x-mac-turkish>
<title>Spor Ceza Sorgu - İstanbul Gençlik ve Spor İl Müdürlüğü</title>
<style type="text/css">
<!--
body,td,th {
font-family: Tahoma, Verdana, Comic Sans MS, Arial;
font-size: 12px;
color: #666666;
}
body {
background-color: #FFFFFF;
}
.style1 {
color: #CC1A00;
font-weight: bold;
}
-->
</style></head>
<body><center>
<form id="form1" name="form1" method="post" action="excel.asp">
<label></label>
<p> </p>
<table width="359" border="1" style="border-collapse:collapse "id="sorgu" cellpadding="1" cellspacing="1" bordercolor="#D2D2D2">
<tr>
<td width="248" align="center" bgcolor="#B3B8FF"><label><strong>TC KİMLİK NO:</strong>
<input name="textalan" type="text" value="44221111333" maxlength="11" />
</label></td>
<td width="69" align="center" bgcolor="#B3B8FF"><label>
<input name="Sorgula" type="submit" id="Sorgula" value="Sorgula" />
</label></td>
</tr>
</table>
<table border="1" width="91%" id="table1" bordercolor="#D2D2D2" cellspacing="1" cellpadding="1" style="border-collapse: collapse">
<tr>
<td width="20%" align="left" bgcolor="#CCD0FF"><b>SOYAD</b></td>
<td width="21%" align="left" bgcolor="#CCD0FF"><b>ADI</b></td>
<td width="20%" align="left" bgcolor="#CCD0FF"><b>ALDIGICEZA</b></td>
<td width="21%" align="left" bgcolor="#CCD0FF"><b>TAKIM_ADI</b></td>
<td width="18%" align="left" bgcolor="#CCD0FF"><b>TC NO</b></td>
</tr>
<%
dim sayi
sayi= CDbl(request.form("textalan"))
response.write("<br /><b>Sorgulanan: </b><span class=""style1"">"& sayi &"</span><br /><br />")
if sayi<>"" then
'--------------------------------------------------------------------------------------------------
baglanti = "DBQ=" & Server.MapPath("xlsveri.xls") & "; DRIVER={Microsoft Excel Driver (*.xls)};"
Set baglantiobje = Server.CreateObject("ADODB.Connection")
Set kayitlarobje = Server.CreateObject("ADODB.Recordset")
baglantiobje.open baglanti
sql="select * from [Sayfa1$]"
kayitlarobje.Open sql, baglantiobje, 1,3
'----------------------------------------------------------------------------------------------------
do while not kayitlarobje.eof
if kayitlarobje("TCNO")= sayi then
%>
<tr>
<td align="left"><%=kayitlarobje("SOYADI")%> </td>
<td align="left"><%=kayitlarobje("ADI")%> </td>
<td align="left"><%=kayitlarobje("ALDIGICEZA")%> </td>
<td align="left"><%=kayitlarobje("TAKIM_ADI")%> </td>
<td align="left"><%=kayitlarobje("TCNO")%> </td>
</tr>
<%
end if
kayitlarobje.movenext
loop
kayitlarobje.close
Set kayitlarobje = nothing
baglantiobje.close
Set baglantiobje = nothing
end if
%>
</table>
</form>
</center>
</body>
</html>
Asp ile excelde sorgulama yapmak
0
●2.466