C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Databinding »

ASP page with database handling


Posted Date: 05 Mar 2009    Resource Type: Code Snippets    Category: Databinding
Author: Miss Meetu ChoudharyMember Level: Diamond    
Rating: 3 out of 53 out of 53 out of 5Points: 15



ASP page with database handling

Here is an Sample Example Which Handles MYSQL 5.0 DataBase with .Net


<%
//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)
%>




Thanks and Regards
Meetu Choudhary
Founder: http://www.msdotnetmentor.com



Responses

Author: Gaurav Arora    06 Mar 2009Member Level: Diamond   Points : 1
Hi Meetu,

You are doing a good job.

Can you provide a same kind of code in asp.net with MySql


Author: Miss Meetu Choudhary    06 Mar 2009Member Level: Diamond   Points : 1
Hello Gaurav ji,

Sure I will Post the same with ASP.NET

Thanks and Regards
Meetu Choudhary



Author: Kumar Velu    07 Mar 2009Member Level: Diamond   Points : 1
Hi Meetu,

This is wat i'm looking for a while.
it's a nice recall for me after a long time in asp.

Thanks a lot

Regards
Kumar


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
MySQL Connetion through ASP  .  ASP DataBase Handling  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Database Binding with Menu Strip n ASP.NET
Previous Resource: Populating drop down list
Return to Discussion Resource Index
Post New Resource
Category: Databinding


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use