ti na xrissipopoio re pedia kai pia i diafora tous? ti einai kalitero?
Episeis exo kai mia erotisi oson afora miaeisagogi egrafis se enan pinaka otan kano to insert kai prin ekteleso tin sql command tha ithela na me prosanatolisei kapios me pion tropo tha elenkso an p.xo kodikos idi eiparxei stin basi oste na mou petaksei analogo minima?
Sas euxaristo ek ton proteron!
Η μέθοδος DSN υπήρχε και υπάρχει ακόμη αλλά πριν ανακαλύψουν την dsn less connection ήταν ο μοναδικός τρόπος σύνδεσης με database σε NT. Τώρα πια υπάρχει φυσικά η dsn less όπου είναι πιο γρήγορη από την DSN στο server και την προτιμούν σχεδόν όλοι πια. ========
Γίνε λίγο πιο σαφής για το insert
enas kodikas tis formas me 2 pedia miazei kapos etsi:
<html>
<head><title>@@@Insert New Record</title></head>
<body bgcolor="black">
<form method="post" action="insertnew.asp">
<center>
<table width="600" border=3 bgcolor="#0099CC" cellpadding="4" cellspacing="0">
<tr>
<td colspan="2" bgcolor="#0099CC">
<center>
<font size="4"><b>insert record </b></font>
</center>
</td>
</tr>
<tr>
<td> <b><font color="yellow"> code</font color></b> </td>
<td>
<input name="code" size="100" maxlength="100">
</td>
</tr>
<tr>
<td> <b><font color="yellow"> skata</font color></b> </td>
<td>
<input name="skata" size="100" maxlength="100">
</td>
</tr>
<tr>
<td> </td>
<td>
<div align="center">
<input type="submit" name="Submit" value="Submit">
</div>
</td>
</tr>
</table>
</center>
<p>
<center><input name="insert" type="1" value="1"></center>
</form>
</body>
</html>
kai o kodikas pou ginete to insert einai autos :
<! code page ellinika >
<% @codepage=1253 %>
<%
insert = TRIM( Request( "INSERT" ))
code = REPLACE(Request.Form("code"), "'", "''")
skata = REPLACE(Request.Form("skata"), "'", "''")
if code = "" then
Response.redirect("form.asp")
end if
if skata = "" then
Response.redirect("form.asp")
end if
Set con = server.createobject( "adodb.connection" )
Set RS = Server.CreateObject( "ADODB.Recordset" )
con.open "test"
%>
<html>
<head><title>Record Successfully Inserted!!!</title></head>
<body bgcolor="#0099CC">
<%
if INSERT <> "" then
sqlstring = "INSERT INTO test " & _
"(code, skata) " & _
"VALUES('" & code & "','" & skata & "')"
con.execute sqlString
con.close
%>
<!kai telika edo mas leei oti tin ebale tin eggrafi mesa stin basi kai exei kai link na prosthesoume kai alli >
<center>
<table width="900" cellpadding="4" cellspacing="0" bgcolor="lightyellow">
<tr>
<td>
<b><center><%=code%> - <%=skata%> </b> Was Added To The Database</center>
</td>
</tr>
</table>
</center>
<p>
<%
end if
%>
<center>
<form name="form1" method="post" action="form.asp">
<input type="submit" name="Submit" value="Insert Another Record">
</form>
</center>
</body>
</html>
1)sorry pou einai tosa polla. pos sou fenete auti i sindesi? dns or dnsless? xrisimopoiontas i dns i dnsless panta diloneis tin basi sto odbc? pia i diafora tous tote!! ti parapano exei?
2) sto insert ama deis apla kano ena sql statement kai kano mia egrafi stin basi. alla giati se auto to paradeigma den exei recordset? mporo na dilono ego ama thelo? exo dei sto utradev kai an kaneis ena query soy petaei kati optimistic kati lock type kai ta sxetika pou anikoun auta stin dns or dnsless?
3) opos eides ston kodika mou thelo na mou peis mia lisi prin na ginete to insert na kano ena select stin basi kai na blepo an eiparxei p.x kai allos codikos o idios
auta pisteuo na min se kourasa
euxaristo poli ek ton proteron!!!
ops eida pos egine post to erotima mou kai sorry an thes dose to mail sou na sou stilo auta ta 2 asp files :)
http://content.aspdir.co.uk/article.asp?article=4
to thema einai pali den apantaei file auto pou thelo :( prin apo to insert thelo na elenxo an eiparxei i idia timi se ena pedio kai apo asp sintaksi eimai scrambas :/ se euxaristo polli anywayz!
Παράδειγμα SQL για error αν το username υπάρχει.
sSQL = "SELECT * FROM Users WHERE UserName = '" & sUserName & "'"
rs.Open sSQL,,,adCmdTable
if not (rs.bof or rs.eof) then
sErr = "Το User name '" & sUserName & "' υπάρχει. Παρακαλώ επιλέξτε άλλο."
bErr = True
end if
Ok file se euxaristo poli :)
tip: Unlimited Profesional ASP.NET 4.0 Hosting.+ MSSQL με 2,30 € το μήνα * F5 για νέο tip