Wawa Recommendations: VBS operation of the database,

  <! – 
  Wawa Recommendations: VBS operation of the database, the realization of this type usually the main database operations, because we are in daily contact and databases, and sometimes the use of such a class is very convenient, but do not know how practical kind, as in performance and there is no error handling a lot to consider, so I do not know how common it. 
  Who can give this category if the dynamic error handling, or to optimize the performance, it is perfect. PS: In order to do this class is a practice of the use of VBS. 
–>
<%
  Class classado 
  Private conn_c 
  Private rs_c 
  Public strconn 
  Private Sub Class_Initialize 'definition of the initialization incident 

  End Sub 

  Private Sub Class_Terminate 'settings Terminate incident.    'Definition of the empty incident 
  Rs_c.close 
  Set rs_c = nothing 
  Conn_c.close 
  Set conn_c = nothing 
  End Sub 

  Public Function opendb () 'open database 
  If isempty (strconn) then 
  Response.Write ( "does not set the database connection string") 
  Response.end 
  End if 
  If isempty (conn_c) then 
  Set conn_c = Server.CreateObject ( "ADODB.Connection") 
  Conn_c.open strconn 
  Else 
  Response.Write (the "database has been opened") 
  Response.end 
  End if 
  End Function 
  Public Function getrs (ByVal strsql) 'Get Set Records 
  If isempty (conn_c) then 
  Opendb () 
  End if 

  Set rs_c = Server.CreateObject ( "ADODB.RecordSet") 
  Rs_c.Open strsql, conn_c, 1,1 
  Set getrs = rs_c 
  End Function 
  Public Function exesql (ByVal strsql) 'implementation of a sql statement, and to insert, update, delete records 
  If isempty (conn_c) then 
  Opendb () 
  End if 
  Conn_c.execute (strsql) 
  End Function 
  End class 
%>
<%
  'On error resume next' debugging procedures when requested to remove sentence 
  Strconn = "Driver sql server = (); server = 192.168.0.110; database = northwind; uid = sa; pwd = sa;" 
  Set c = new classado 
  C.strconn = strconn 
  C.opendb () 
  Strsql = "SELECT EmployeeID, TitleOfCourtesy''+''+ + + LastName FirstName AS fullname FROM Employees" 
  Arr_wawa = c.getrs (strsql). Getrows () 
  C.getrs set rs = (strsql) 
%>
  <table Width="100%" border="0" cellspacing="1"> 
<%
  If not rs.eof Then 
  For i = 0 to rs.fields.count-1 
  Response.write rs.fields (i). Name & "" 
  Next 
  Response.write "<br>" 
  Do while not rs.eof 
  For i = 0 to rs.fields.count-1 
  Response.write rs.fields (i). Value & "" 
  Next 
  Response.write "<br>" 
  Rs.movenext 
  Loop 
  End if 
%>
<hr>

  <table Width="100%" border="0" cellspacing="1"> 
  <% If not isempty (arr_wawa) Then%> 
  <% For i = 0 to ubound (arr_wawa, 2)%> 
<tr>
  <% For j = 0 to ubound (arr_wawa, 1)%> 
  <td> <% = Arr_wawa (j, i)%> </ td> 
  <% Next%> 
  </ Tr> 
  <% Next%> 
  <Else%%> 
<tr>
  <td> There is no record of </ td> 
  </ Tr> 
  <End If%%> 
  </ Table> 

Bookmark it: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Google
  • DotNetKicks
  • DZone
  • Furl
  • Netvouz

Tags:

Releated Articles


0 Comments to “Wawa Recommendations: VBS operation of the database,”

No Comments. Send your comment.

Leave a Reply

You must be logged in to post a comment.