Results 1 to 5 of 5

Thread: SQl Statement returns value "System.Byte[]"

  1. #1

    Thread Starter
    Fanatic Member snufse's Avatar
    Join Date
    Jul 2004
    Location
    Jupiter, FL
    Posts
    912

    SQl Statement returns value "System.Byte[]"

    I have a sql select, and some of the fields have return value of "System.Byte[]". Fields are all character and they all have values. Can anyone explain what this means? Thank you.

  2. #2
    Frenzied Member
    Join Date
    Aug 2005
    Posts
    1,042

    Re: SQl Statement returns value "System.Byte[]"

    snufse:

    It is kind of hard for anyone to speculate about your SQL select statement without seeing your code.

    Also, it might be helpful to know what type of database you are using.

  3. #3

    Thread Starter
    Fanatic Member snufse's Avatar
    Join Date
    Jul 2004
    Location
    Jupiter, FL
    Posts
    912

    Re: SQl Statement returns value "System.Byte[]"

    I am connecting to db2 retrieving a single record.

    Here is the code:

    VB Code:
    1. Dim MyConnection As Odbc.OdbcConnection = New Odbc.OdbcConnection
    2.         MyConnection.ConnectionString = "Driver={Client Access ODBC Driver (32-bit)};System=vgsys400;Uid=vgwprja;Pwd=ammt7584;"
    3.         MyConnection.Open()
    4.  
    5.         Dim MyCommand As Odbc.OdbcCommand = New OdbcCommand
    6.         MyCommand.CommandText = "SELECT YAALPH from VGIPRDHRP.F060116 where YAAN8 =" + EmpCode.ToString
    7.         MyCommand.CommandType = CommandType.Text
    8.         MyCommand.ExecuteScalar()
    9.  
    10.         Dim MyAdapter As New Odbc.OdbcDataAdapter
    11.         MyAdapter.SelectCommand = MyCommand
    12.         Dim MyDataSet As New DataSet
    13.         Dim MyDataTable As New DataTable
    14.  
    15.         MyAdapter.Fill(MyDataTable)
    16.         TextBox1.Text = MyDataTable.Rows(0).Item(0).ToString
    17.        
    18.         MyConnection.Close()
    Last edited by si_the_geek; Feb 12th, 2007 at 10:46 AM. Reason: added vbcode tags

  4. #4

    Thread Starter
    Fanatic Member snufse's Avatar
    Join Date
    Jul 2004
    Location
    Jupiter, FL
    Posts
    912

    Red face Re: SQl Statement returns value "System.Byte[]"

    Solution:

    When connecting to db2 and selecting data and a field value is represented as binary or hexdecimal data is normally not translated. Following will solve this problem. In the connection string insert following: "Translate=1".

    So my complete connection string now reads:

    MyConnectionString = "Driver={Client Access ODBC Driver (32-bit)}; System=vgsys400; Translate=1; Uid=vgwprja; Pwd=ammt7584;"

    This will solve the problem.

  5. #5
    New Member
    Join Date
    Jul 2017
    Posts
    1

    Re: SQl Statement returns value "System.Byte[]"

    10 years later, you saved the day for me

Posting Permissions

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



Click Here to Expand Forum to Full Width