2013-03-11 1 views
1
여기

1 개 차원 어레이로 변환 할 수없는 선언이다값 바이트

Public Class Client 
Public Property Address() As String 
    Get 
     Return mAddress 

    End Get 
    Set(ByVal value As String) 
     mAddress = value 
    End Set 
End Property 
Public Property City() As String 
    Get 
     Return mCity 

    End Get 
    Set(ByVal value As String) 
     mCity = value 
    End Set 
End Property 
end sub 

에러가 여기에있다 "

Public Function InsertClientRecordToDb(ByVal cli As Client) As Boolean 
     Dim retVal As Boolean 
     Dim dataSet As DataSet = New DataSet("dataSet") 
     dataSet.EnforceConstraints = False 
     'create table adapter object 
     Dim ClientTblAdapter As New CaseStudyDBDataSetTableAdapters.Client_TableTableAdapter 

    'check db connection 
    If ClientTblAdapter.Connection.State = ConnectionState.Closed Then 
     ClientTblAdapter.Connection.Open() 
    End If 

    'perform(insert) 
    If ClientTblAdapter.InsertClientRecord(cli.Clientcode, cli.Clientname, cli.Address, cli.City, cli.Contactperson, cli.Contactnumber) > 0 Then 
     retVal = True 
    End If** 

    Return retVal 
End Function 

은"cli.Address "및 String 형의

값은 바이트

,536의 1 개 차원 배열로 변환 할 수 없습니다 cli.City "는 말을 강조했다

무엇이 문제입니까? 당신이 Byte()

뭔가 마음에 문자열을 할당하려고 같은 오류

+0

InsertClientRecord는 어떻게 정의됩니까? – djv

답변

1

이 보인다 : 당신이 Encoding 클래스를 사용할 필요가 잘못

Dim bArr As Byte() = "hello world!" 

Byte()에 문자열을 변환하는

Dim bArr As Byte() = System.Text.Encoding.Default.GetBytes("hello world!")