dcsimg
Page 2 of 2 FirstFirst 12
Results 41 to 47 of 47

Thread: SQL server connection string

  1. #41

    Thread Starter
    Addicted Member Peekay's Avatar
    Join Date
    Sep 2006
    Location
    Witbank, South Africa
    Posts
    193

    Re: SQL server connection string

    Double post sorry
    Last edited by Peekay; Apr 18th, 2019 at 05:27 AM.

  2. #42

    Thread Starter
    Addicted Member Peekay's Avatar
    Join Date
    Sep 2006
    Location
    Witbank, South Africa
    Posts
    193

    Re: SQL server connection string

    Hi Olaf,

    Before we move ahead, there are a few things I do not understand.

    1. I understand the routine "ReflectString" quite well, because you use a string to reflect.
    2. In "TransferByteArrays" you also manipulate alpha-numeric characters. Why do you use Bytes for this? I have not worked with byte arrays before, but somehow followed your explanation, but I do not follow it in a methodical or understandable way.
    3. Sometimes you use RsIn(1) and RsIn(2) and other times you use Rsin.Fields(1).value. Should I not be consistent in using the same input type of ADO and abstracting data from it in a consistent manner?
    4. I understand partly that we will mostly work with multiple strings as parameters, so I understand that we need to work in arrays, but I am not sure what is the purpose of working in arrays in one place and with fields in another.

    PK

  3. #43
    PowerPoster
    Join Date
    Jun 2013
    Posts
    4,115

    Re: SQL server connection string

    Quote Originally Posted by Peekay View Post
    1. I understand the routine "ReflectString" quite well, because you use a string to reflect.
    That's good, because a String is basically the same as a ByteArray (an allocation of consecutive memory - containing a sequence of bytes aka "chars").

    Quote Originally Posted by Peekay View Post
    2. In "TransferByteArrays" you also manipulate alpha-numeric characters. Why do you use Bytes for this?
    I have not worked with byte arrays before, but somehow followed your explanation, but I do not follow it in a methodical or understandable way.
    The emphasis is on "Transfer" in this case -
    the "manipulation of content" (no matter if the byte-sequence is in a string or a bytearray) is not that important -
    it's only there as a kind of "proof", that the passed String or ByteArray was "indeed received and touched" at the serverside...

    Quote Originally Posted by Peekay View Post
    3. Sometimes you use RsIn(1) and RsIn(2) and other times you use Rsin.Fields(1).value.
    Should I not be consistent in using the same input type of ADO and abstracting data from it in a consistent manner?
    When you read out a Value like that:
    SomeValue = RsIn(1)
    then this is absolutely the same as:
    SomeValue = RsIn.Fields(1).Value
    because .Fields is a default-property of the ADO-Recordset-Class - and .Value is a Default-Property of the ADO-Field-Class (which you've addressed via the parentheses).
    (the VB6-compiler kind of "auto-expands" the short-form under the covers).

    If you are into "writing explicit, nice code", then use the longer (expanded form).

    Quote Originally Posted by Peekay View Post
    4. I understand partly that we will mostly work with multiple strings as parameters,
    so I understand that we need to work in arrays,
    but I am not sure what is the purpose of working in arrays in one place and with fields in another.
    The necessity to work with "Rs-Fields" comes from choosing ADO-Rs as the transport-container-format for Input- and Output of the RPC-http-Requests
    (due to the reason, that an ADO-Rs can take up multiple Field-Types in its Variant-Fields - but especially because an ADO-Rs can be serialized to a "sequence of Bytes",
    which is a necessity, when you transfer "stuff over sockets/network-connections".

    As for the similarities between ByteArrays and Strings - you might take a good long look at the following:
    Code:
    Private Sub Form_Load()
      Dim S As String, B() As Byte
      
      'Unicode-WChar-Mode (16Bit=2Bytes per Char)
          S = "ABC"
          B = S 'implicit conversion from String to ByteArray-Type (making a content-copy)
          Debug.Print B, S, UBound(B) + 1, LenB(S)
          
          'explicit filling of B in unicode-mode
          ReDim B(0 To 5) 'Bytes = 6, WChars = 3
                B(0) = 65
                B(2) = 66
                B(4) = 67
          Debug.Print B, S, UBound(B) + 1, LenB(S)
     
     
      'ANSI-Char-Mode (8Bit=1Byte per Char)
          S = StrConv(S, vbFromUnicode) 'make an ANSI-String from the Unicode-String
          B = S 'implicit conversion from String to ByteArray-Type (making a content-copy)
          Debug.Print StrConv(B, vbUnicode), StrConv(S, vbUnicode), UBound(B) + 1, LenB(S)
          
          'explicit filling of B in ANSI-mode
          ReDim B(0 To 2) 'Bytes = 3, Chars = 3
                B(0) = 65
                B(1) = 66
                B(2) = 67
          Debug.Print StrConv(B, vbUnicode), StrConv(S, vbUnicode), UBound(B) + 1, LenB(S)
    End Sub
    HTH

    Olaf

  4. #44

    Thread Starter
    Addicted Member Peekay's Avatar
    Join Date
    Sep 2006
    Location
    Witbank, South Africa
    Posts
    193

    Re: SQL server connection string

    Name:  Resultset.jpg
Views: 24
Size:  8.6 KB

    Here is my code for returning the same string and I can see the Resultset is correct, but it does not print the result in the grid, but prints and error number in stead:

    Public Sub TransferString()
    Dim S As String
    S = RsIn.Fields(1).Value
    Set RsOut = CreateResultRs("TransferString", S)
    End Sub

  5. #45
    Addicted Member
    Join Date
    Aug 2016
    Posts
    152

    Re: SQL server connection string

    It is painful to follow up the steps for such old man...

  6. #46
    PowerPoster
    Join Date
    Jun 2013
    Posts
    4,115

    Re: SQL server connection string

    Quote Originally Posted by Peekay View Post
    Here is my code for returning the same string ...

    Public Sub TransferString()
    Dim S As String
    S = RsIn.Fields(1).Value
    Set RsOut = CreateResultRs("TransferString", S)
    End Sub
    Ok, the above looks right now (for transferring or "roundtripping" a simple String).
    Now show me your implementation for an appropriately named serverside HandlerRoutine, which does the same for the ByteArray-Type.

    As for the Errors you might see at the clientside...
    These might occur, when you spend too many seconds in the Serverside routines in "Break-Point-Mode" -
    because the clientside (async) httprequest might have run into a timeout in the meantime.

    If you remove all breakpoints, and start the whole thing from a correctly written clientside DoRPC-call,
    you should see correct results coming in at the clientside (in your Form-Code).

    Olaf

  7. #47

    Thread Starter
    Addicted Member Peekay's Avatar
    Join Date
    Sep 2006
    Location
    Witbank, South Africa
    Posts
    193

    Re: SQL server connection string

    Quote Originally Posted by DaveDavis View Post
    It is painful to follow up the steps for such old man...
    Thanks for the sympathy David, But once I get going nothing will stop me.
    I started with Fortran IV on mainframes in 1968 and still going strong!

    Kind regards

Page 2 of 2 FirstFirst 12

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width