|
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
<%@ 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>
|