ASP page with database handling
Here is an Sample Example Which Handles MYSQL 5.0 DataBase with .Net
[code]
<%
//This page will be refreshed with each access!
Response.Expires=-1
%>
<%
//create connection object
set con=server.createobject("adodb.connection")
//Conection String and open the connection
call con.open("provider=msdasql;driver={Mysql};server=mysqlServerName;uid=username;pwd=password;database=dbnsme;")
//For Select Query Execution
set rs=con.execute("select * from tablename )
//displaying the records in a table format
//loop till rs has records
while not rs.eof
response.write("<tr><td>" & rs.fields(0) & "</td><td>" & rs.fields(1) & "</td></tr>")
rs.movenext
wend
rs.close()
response.write("</table>")
//Update Process
//update query
//a will contain how mny records are modified
con.execute("Upadte Query goes here"),a
response.write(a & " records updated")
//response.write("Done")
//Insert Process
//insert query
con.execute("insert into RegClLog (SrNo,ProdKey,ClDtTm) values('"& request.form("hidSrno") &"','"& request.form("hidResult") &"','"& request.form("hidClDtTym") &"') "),a
response.write(a & " records Inserted")
//close connection
con.Close()
%>
<html>
<head></head>
<body>
<form action="#" method="post">
Any HTML CODE here will run perfectly. to display the page
</form>
</body>
</html>
//Trapping Errors in ASP.
//This will get the last error occurred.
<%
dim objErr
set objErr=Server.GetLastError()
response.write("ASPCode=" & objErr.ASPCode)
response.write("
")
response.write("ASPDescription=" & objErr.ASPDescription)
response.write("
")
response.write("Category=" & objErr.Category)
response.write("
")
response.write("Column=" & objErr.Column)
response.write("
")
response.write("Description=" & objErr.Description)
response.write("
")
response.write("File=" & objErr.File)
response.write("
")
response.write("Line=" & objErr.Line)
response.write("
")
response.write("Number=" & objErr.Number)
response.write("
")
response.write("Source=" & objErr.Source)
%>
[/code]
Thanks and Regards
Meetu Choudhary
Founder: http://www.msdotnetmentor.com
Subscribe to:
Post Comments (Atom)
Subscribe via email
MSDotnetMentor
MSDotnetMentor
My Website
http://msdotnetmentor.com
Author
Blog Archive
-
▼
2009
(53)
-
▼
March
(14)
- Silverlight 3- Beta - released
- Creating Calender Using Java Script
- Blinking Text Using JavaScript
- Use a session variable in the class files in c# AS...
- ASP page with database handling
- Keycodes at a glance
- JavaScript String Replace All
- Type Text in Upper Case using CSS
- No scrollbar on HTML web pages - JavaScript code
- Transparent or Hide Scrollbar
- disable scroll bar
- Show or Hide combobox at Runtime using JavaScript
- Sending Email Through ASP.NET using C#
- Overview of ASP.Net Framework
-
▼
March
(14)
No comments:
Post a Comment