Results 1 to 2 of 2

Thread: VB COM

  1. #1
    Join Date
    Dec 1969

    Default VB COM

    QUESTION 1:<BR>When using a VB COM object to connect to a database which is better to output the HTML results. To do objASPResponse.write and a loop from the VB Object, or to build a string with a loop and return the string to the ASP page, or to return maybe an array(from rs.getRows) to the ASP page and do the loop in the ASP page?<BR><BR><BR>Question 2:<BR>I usually just do everything is ASP, not in COM Objects. So can someone help me through this. I usually do something like this to get data from a database:<BR>Dim objConnTemp,objRSTemp,arryRS,strDSN<BR>strDSN = <BR>set objConnTemp=server.createobject("adodb.connection" )<BR>objConnTemp.CommandTimeout = 120<BR>objConnTemp.ConnectionTimeout= 30<BR>objConnTemp.ConnectionString = strDSN<BR>objConnTemp.open<BR>set objRSTemp = objConnTemp.Execute("sp_search")<BR>if not objRSTemp.eof then<BR> arryRS = objRSTemp.GetRows<BR>end if<BR>&#039loop through it here.<BR>I usually don&#039t use "ADODB.Command" or "ADODB.Recordset", but as I have been looking at a lot of VB Sample Code, I see that most of them use both "ADODB.Command" and "ADODB.Recordset". Should I now change my usual practices and do this too? And if not then how in my VB code will I dim arryRS and objRSTemp.<BR>Private objRSTemp as ?????<BR>Private arryRS as As Variant ?????<BR><BR>Thanks to anyone that can help me out here. Also, any sample code is appreciated.

  2. #2
    Steve Cimino Guest

    Default Early binding vs Late binding

    Answer 1:<BR>Preference. I don&#039t do it personally, but that doesn&#039t mean it shouldn&#039t be done. I like to break down all business rule processing in COM, and then send it back to ASP to display results (this includes all HTML formatting)<BR><BR>Answer2<BR>YOu can do one of two things. Please read up on the concepts of early binding and late binding.<BR><BR>Dim x as object &#039Late Binding<BR>Set x = New ADODB.Connection<BR>&#039yadda yadda yadda<BR><BR><BR>&#060;OR&#062;<BR>Dim x as new ADODB.Connection &#039early binding<BR>&#039yadda yadda yadda<BR><BR>In the first example, VB knows there is an object being set in memory, however, it doesn&#039t know what or how big. So to compensate, it allocates the most memory.<BR><BR>In the second (more efficient) example, you&#039re telling VB to create a connection object, and it allocates the memory more appropriately.<BR><BR>There&#039s more to it than this... I suggest to search through MSDN and read up on these topics.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts