.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

")
rs.movenext
wend
rs.close()
response.write("
Home >> Articles >> DataBase >> Post New Resource Bookmark and Share   

 Subscribe to Articles

ASP page with database handling

Posted By:Meetu Choudhary       Posted Date: June 08, 2009    Points: 25    Category: DataBase    URL: http://www.dotnetspark.com  
 

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("
" & rs.fields(0) & "" & rs.fields(1) & "
")


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





Any HTML CODE here will run perfectly. to display the page






//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
 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend