E:\web\learnaspcom\htdocs\freebook\learn\ubtoc.xml LearnAsp.com - ASP ASP.net Free Lessons
Search Search

#1 worldwide
FREE Coding Lessons

since 1996
   THE BEST WAY to learn ASP & Asp.net!
Advertise Here!
click for details
Credits Host:
DiscountASP.net
Server Admin:
The "Team"
Contact Info.
Charles M. Carroll
<Asp.net blog>
<personal site>
xxx

Utility Belt: SQLGenerateInsert and DbExec Demo
by Charles Carroll

The code below calls "Utility Belt" functions.

   filename=/experiments/utilitybelt/vernext/ubdemo_dbexec_sqlserver.aspx

<Test Script Below>


<%@ debug="true" %>
<%@ Import Namespace="System.data"%>
<%@ Import Namespace="LearnAsp"%>
<%@ Assembly src="utilitybelt.vb" %>
<script language="VB" runat="server">
    dim ub1 as new utilitybelt()
    dim strConnect as string
Sub Page_Load(S As Object, E As EventArgs)
    trace.tracemode=TraceMode.SortByTime
    ub1.Options("SuperTrace=on,Debug=On,Advice=On")
    
    strConnect="LearnaspSamplesFull"
    dim strSQLcount as string="select count(*) from publishers"
    
    DIM intrecCount as integer
    ub1.DBPopulate(strConnect,strSQLcount,intRecCount)
    litStatus.text & = intRecCount & " records in publishers now...."
    
    DIM htInsert as new hashtable
    DIM strSQLinsert as string
    htInsert("table_name")="publishers"
    htInsert("name")="fc"
    htInsert("company name")="Fake Company"
    htInsert("address")="PO box xxx"
    htInsert("city")="Fake City"
    htInsert("state")="ZZ"
    htInsert("zip")="55555"
    htInsert("telephone")="555-1212"
    htInsert("fax")="555-1212"
    htInsert("comments")="Just testing DbExec to add a record"
    strSQLinsert=ub1.SQLGenerateInsert(strConnect,htInsert)
    ub1.Dbexec(strConnect,strSQLInsert)

    ub1.DBPopulate(strConnect,strSQLcount,intRecCount)
    litStatus.text & = "<br>" & intRecCount & " records in publishers now after DBExec...."    
    
    ub1.DbExec(strConnect,"delete from publishers where state='ZZ'")
    
    ub1.DBPopulate(strConnect,strSQLcount,intRecCount)
    litStatus.text & = "<br>" & intRecCount & " records in publishers now after deleting with DbExec...."
End Sub
</script>
<html><head>
<title>Utility Belt Demo</title>
</head>
<body bgcolor="#FFFFFF">
<asp:literal id="litStatus" runat="server" />
<asp:placeholder id="plcErr" runat="server"/>
</body></html>
Chaz Wish List
Tall Tip $5
Grande Tip $20
Venti Tip $39
Tip Jar Thanks
2004 Thanks
2005 Thanks
HUGE Tip -love site