Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
This script is a pseudo wizard, that allows to gen...
Author:
Santi Mondejar
E-mail:
Click to e-mail author
Submitted:
8/3/2000
Version:
ASP
Compatibility:
ASP
Category:
ASP
Views:
16516
This script is a pseudo wizard, that allows to generate automatically an HTML form from a SQL query. Additionally, inserts the data contained in the form in the data base. It is only necessary to indicate the the data base reference, and the query that we want to execute. The code is easily customizable.
Declarations:
'none
Code:
<% if len(Request.QueryString) = 0 then 'First call Set db_cnx = Server.CreateObject("ADODB.Connection") db_path="DBQ=" & server.mappath("db1.mdb") Session("source")= db_path db_cnx.Open "DRIVER={Microsoft Access Driver (*.mdb)}; " & Session("source") Sql1 = " SELECT * FROM some_table " Session("sql")=Sql1 Set db_rcdst1 = Server.CreateObject("ADODB.Recordset") db_rcdst1.Open Session("sql"), db_cnx, 1, 2 %>
" method="get" >
<% for i=0 to db_rcdst1.fields.count-1 %>
<%=db_rcdst1(i).name %>
size=<%=db_rcdst1(i).definedsize %>>
<%next%>
<% Else 'Second call Set db_cnx = Server.CreateObject("ADODB.Connection") db_cnx.Open "DRIVER={Microsoft Access Driver (*.mdb)}; " & Session("source") Set db_rcdst1 = Server.CreateObject("ADODB.Recordset") db_rcdst1.Open Session("sql"), db_cnx, 1, 2 Set db_rcdst2 = Server.CreateObject("ADODB.Recordset") db_rcdst2.Open Session("sql"), db_cnx, 1, 2 'starting database writing db_rcdst1.AddNew a=db_rcdst1.fields.count For Each Key In Request.QueryString a=a-1 val_type=Request.QueryString(key) obj_width = db_rcdst2(a).definedsize clase = db_rcdst2(a).type Select case clase rem VarType(db_rcdst2(a)) Case 2 val_type = Cint(val_type) Case 3 val_type = Clng(val_type) Case 4 val_type = Csng(val_type) Case 5 val_type = Cdbl(val_type) Case 6 val_type = Ccur(val_type) Case 135 If IsDate(val_type) Then val_type = Cdate(val_type) Else val_type=Date End If Case 200 var_type="Cstr" val_type = Cstr(Left(val_type, obj_width)) Case 11 If Ucase(val_type) = "true" Then val_type = True Else val_type = False End If Case 17 var_type="Cbyte" val_type = Cbyte(val_type) End Select db_rcdst1(a)=val_type Next db_rcdst1.Update db_rcdst1.Close db_rcdst2.Close Set db_rcdst1 = Nothing Set db_rcdst2 = Nothing Session.Abandon Response.Write("information have been registered") finish=True End If%>
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement