afroz khan

afroz khan

  • NA
  • 62
  • 0

Value of type 'Byte' cannot be converted to '1-dimensional array of Byte'

Sep 24 2008 12:52 AM

I have run this code in c# and  it's working properly but when convert it in vb.net

generating error

The error occurs on the line that follows:

Dim obj As Byte() = CByte(cmd.ExecuteScalar())

Response.BinaryWrite(CByte(cmd.ExecuteScalar()))

 

This is my code

Protected Sub View_Click(ByVal sender As Object, ByVal e As EventArgs)

Dim stream As New IO.MemoryStream()Dim strcon As String = "Data Source=(local) ;Initial Catalog=SaveImage; User ID=***; Password=***;"

Dim con As New SqlConnection(strcon)

con.Open()

'string strcmd = "select Doc from trn_Image where iDocID=" + Convert.ToInt32(TextBox2.Text);

'string strcmd = " select * from trn_Image where cReportType=" + Convert.ToString(TextBox2.Text);

Dim cmd As New SqlCommand("Select * from trn_Image where cReportType= @cReportType", con)

cmd.Parameters.Add("@cReportType", SqlDbType.VarChar)

cmd.Parameters("@cReportType").Value = TextBox1.Text

 

'SqlCommand cmd = new SqlCommand(strcmd,con);

Dim obj As Byte() = CByte(cmd.ExecuteScalar())

 

Response.ContentType = "Application/msword"

Response.BinaryWrite(CByte(cmd.ExecuteScalar()))

Response.[End]()

 

 

con.Close()

End Sub


Answers (1)