AllExperts > Experts 
Search      

VB.NET

Volunteer
Answers to thousands of questions
 Home · More Questions · Answer Library  · Encyclopedia ·
More VB.NET Answers
Question Library

Ask a question about VB.NET
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Syed Rizwan Muhammad Rizvi
Expertise
I can answers questions regarding web based and desktop based programming in VB.Net. Which can include SOAP, XML, Custom Controls, COM Interoperability etc.

Experience
Have been working in this specific area for last 2 years previously I was a VB 6 Developer with experties in other languages as well. Total 10 years of programming experience.

 
   

You are here:  Experts > Computing/Technology > Basic > VB.NET > Error = Only byte array and strings can be serialize by MySqlBinary

Topic: VB.NET



Expert: Syed Rizwan Muhammad Rizvi
Date: 11/11/2006
Subject: Error = Only byte array and strings can be serialize by MySqlBinary

Question
The below code is my save code

Private Sub cmdsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdsave.Click
       Dim myCommand As New MySqlCommand
       Dim txn As MySqlTransaction
       Dim strcolorfcov As String
       Dim strcolorbcov As String
       Dim strcolorfcon1 As String
       Dim strcolorbcon1 As String
       Dim strcolorfcon2 As String
       Dim strcolorbcon2 As String
       Dim strcolorfcon3 As String
       Dim strcolorbcon3 As String
       Dim strcolorfrontcover As String
       Dim strcolorbackcover As String
       Dim strcolorfrontcontent As String
       Dim strcolorbackcontent As String
       Dim strfinishing As String
       Dim strReference As String
       Dim strjobno As String
       Dim strentity As String
       Dim strothrfcolorcov As String
       Dim strothrbcolorcov As String
       Dim strothrfcolorcon1 As String
       Dim strothrbcolorcon1 As String
       Dim strothrfcolorcon2 As String
       Dim strothrbcolorcon2 As String
       Dim strothrfcolorcon3 As String
       Dim strothrbcolorcon3 As String
       Dim strfname As String = ""
       Dim strfname1 As String = ""

       'chkother.Checked = True
       strothrfcolorcov = txt1.Text & "+" & txt5.Text & "+" & txt9.Text & "+" & txt13.Text & "+" & txt17.Text & "+" & txt21.Text
       strothrbcolorcov = txt25.Text & "+" & txt29.Text & "+" & txt33.Text & "+" & txt37.Text & "+" & txt41.Text & "+" & txt45.Text
       strothrfcolorcon1 = txt2.Text & "+" & txt6.Text & "+" & txt8.Text & "+" & txt10.Text & "+" & txt14.Text & "+" & txt16.Text
       strothrbcolorcon1 = txt26.Text & "+" & txt30.Text & "+" & txt34.Text & "+" & txt38.Text & "+" & txt42.Text & "+" & txt46.Text
       strothrfcolorcon2 = txt3.Text & "+" & txt7.Text & "+" & txt11.Text & "+" & txt15.Text & "+" & txt19.Text & "+" & txt23.Text
       strothrbcolorcon2 = txt27.Text & "+" & txt31.Text & "+" & txt35.Text & "+" & txt39.Text & "+" & txt43.Text & "+" & txt47.Text
       strothrfcolorcon3 = txt4.Text & "+" & txt8.Text & "+" & txt12.Text & "+" & txt16.Text & "+" & txt20.Text & "+" & txt24.Text
       strothrbcolorcon3 = txt28.Text & "+" & txt32.Text & "+" & txt36.Text & "+" & txt40.Text & "+" & txt44.Text & "+" & txt48.Text
       strcolorfcov = cbo1.Text & "+" & cbo5.Text & "+" & cbo9.Text & "+" & cbo13.Text & "+" & cbo17.Text & "+" & cbo21.Text
       strcolorbcov = cbo25.Text & "+" & cbo29.Text & "+" & cbo33.Text & "+" & cbo37.Text & "+" & cbo41.Text & "+" & cbo45.Text
       strcolorfcon1 = cbo2.Text & "+" & cbo6.Text & "+" & cbo10.Text & "+" & cbo14.Text & "+" & cbo18.Text & "+" & cbo22.Text
       strcolorbcon1 = cbo26.Text & "+" & cbo30.Text & "+" & cbo34.Text & "+" & cbo38.Text & "+" & cbo42.Text & "+" & cbo46.Text
       strcolorfcon2 = cbo3.Text & "+" & cbo7.Text & "+" & cbo11.Text & "+" & cbo15.Text & "+" & cbo19.Text & "+" & cbo23.Text
       strcolorbcon2 = cbo27.Text & "+" & cbo31.Text & "+" & cbo35.Text & "+" & cbo39.Text & "+" & cbo43.Text & "+" & cbo47.Text
       strcolorfcon3 = cbo4.Text & "+" & cbo8.Text & "+" & cbo12.Text & "+" & cbo16.Text & "+" & cbo20.Text & "+" & cbo24.Text
       strcolorbcon3 = cbo28.Text & "+" & cbo32.Text & "+" & cbo36.Text & "+" & cbo40.Text & "+" & cbo44.Text & "+" & cbo48.Text
       strcolorfrontcover = strcolorfcov & "+" & strothrfcolorcov
       strcolorbackcover = strcolorbcov & "+" & strothrbcolorcov
       strcolorfrontcontent = strcolorfcon1 & "+" & strcolorfcon2 & "+" & strcolorfcon3 & "+" & strothrfcolorcon1 & "+" & strothrfcolorcon2 & "+" & strothrfcolorcon3
       strcolorbackcontent = strcolorbcon1 & "+" & strcolorbcon2 & "+" & strcolorbcon3 & "+" & strothrbcolorcon1 & "+" & strothrbcolorcon2 & "+" & strothrbcolorcon3

       strentity = "AS"
       strjobno = GetDocno(strentity)
       strfname = OpenFileDialog1.FileName
       strfname1 = OpenFileDialog2.FileName


       strfinishing = strVarnish & strUV & strFront & strHotStamping & strBlock & strEmboss & strNew & strDieCutting & strMould & strFolding & strHand & strCreasing & strGlue & strGhand & strStitch & strLaminate & strMatt & strMattFront & strGloss & strString & strPunch & str3mm & strOther
       strReference = strkeep & stragent

       myCommand.Connection = conn
       txn = myCommand.Connection.BeginTransaction
       myCommand.CommandText = " INSERT INTO prodjof ( JobNo, CoName, PIC, Tel, Hp, Fax, DateOrder, DateDeliver,  ProofReadDate, " & _
                               " CBno, PORef, inv, price, Qty, PaperCode,MouldCode,Hole, SideGlue, ordertype, Width, Height, color, colorB,colorCNTF, colorCNTB,PaperCodeCNT," & _
                               " JODateSend, Remarks, TypeSetter, PC, Refer, Reference, FileName, OrderBy, Size, OrderDesc, FrontFileName ,BackFileName,  package, sideCover, sideCNT, CTPProofReadDate, Set )" _
                               & "VALUES (?JobNo, ?CoName, ?PIC, ?Tel, ?Hp, ?Fax, ?DateOrder, ?DateDeliver,  ?ProofReadDate, " & _
                               "?CBno, ?PORef, ?inv, ?price, ?Qty, ?PaperCode, ?MouldCode,?Hole, ?SideGlue," & _
                               "?ordertype, ?Width, ?Height, ?color,?colorB, ?colorCNTF,?colorCNTF, ?PaperCodeCNT, ?JODateSend, ?Remarks, ?TypeSetter, ?PC, ?Refer, " & _
                               "?Reference, ?FileName, ?OrderBy, ?Size, ?OrderDesc, ?FrontFileName, ?BackFileName, ?package, ?sideCover, ?sideCNT, ?CTPProofReadDate, ?Set )"

       myCommand.Parameters.Add("?CoName", txtconame.Text)
       myCommand.Parameters.Add("?Tel", txttel.Text)
       myCommand.Parameters.Add("?Hp", txthp.Text)
       myCommand.Parameters.Add("?Fax", txtfax.Text)
       myCommand.Parameters.Add("?PIC", txtpic.Text)
       myCommand.Parameters.Add("?DateOrder", DateTimePicker1.Value)
       myCommand.Parameters.Add("?DateDeliver", DateTimePicker2.Value)
       myCommand.Parameters.Add("?ProofReadDate", DateTimePicker3.Value)
       myCommand.Parameters.Add("?CTPProofReadDate", DateTimePicker4.Value)
       myCommand.Parameters.Add("?CBno", txtcb.Text)
       myCommand.Parameters.Add("?PORef", txtpo.Text)
       myCommand.Parameters.Add("?price", txtprice.Text)
       'myCommand.Parameters.Add("?Qty", txtqty.Text)
       'myCommand.Parameters.Add("?Qty", txtqtyb.Text)
       myCommand.Parameters.Add("?Set", txtset.Text)
       myCommand.Parameters.Add("?PaperCode", cbopaper1.Text)
       myCommand.Parameters.Add("?PaperCodeCNT", cbopaper2.Text)
       myCommand.Parameters.Add("?ordertype", txtjobname.Text)
       myCommand.Parameters.Add("?color", strcolorfrontcover)
       myCommand.Parameters.Add("?colorB", strcolorbackcover)
       myCommand.Parameters.Add("?colorCNTF", strcolorfrontcontent)
       myCommand.Parameters.Add("?colorCNTB", strcolorbackcontent)
       myCommand.Parameters.Add("?JODateSend", DateTimePicker2.Value)
       myCommand.Parameters.Add("?Remarks", txtremarks.Text)
       myCommand.Parameters.Add("?TypeSetter", txttypesetter.Text)
       myCommand.Parameters.Add("?OrderBy", txtorderby.Text)
       myCommand.Parameters.Add("?PC", txtpc.Text)
       myCommand.Parameters.Add("?FileName", txtfilename.Text)
       myCommand.Parameters.Add("?Size", txtheight.Text & " x " & txtwidth.Text & " mm")
       myCommand.Parameters.Add("?Height", txtheight.Text)
       myCommand.Parameters.Add("?Width", txtwidth.Text)
       myCommand.Parameters.Add("?OrderDesc", strfinishing)
       myCommand.Parameters.Add("?Reference", strReference)
       myCommand.Parameters.Add("?JobNo", strjobno)
       myCommand.Parameters.Add("?FrontFileName", strfname)
       myCommand.Parameters.Add("?BackFileName", strfname1)
       myCommand.Parameters.Add("?package", "Packaging")
       myCommand.Parameters.Add("?SideGlue", txtside.Text)
       myCommand.Parameters.Add("?Hole", txthole.Text)
       myCommand.Parameters.Add("?MouldCode", txtcode.Text)
       myCommand.Parameters.Add("?Height", txtheighto.Text)
       myCommand.Parameters.Add("?Width", txtwidtho.Text)
       myCommand.Parameters.Add("?Size", txtheighto.Text & " x " & txtwidtho.Text & " mm")



       If chkvarnish.Checked = True Then
           strVarnish = " Varnish"
           If chkuv.Checked = True Then
               strUV = " (UV)+"
           ElseIf chkspot.Checked = True Then
               strUV = " (SpotUV)+"
           Else
               strUV = " (Overpoint"
               If chkfront.Checked = True Then
                   strFront = " (Front))+"
               Else
                   strFront = " (Back))+"
               End If
           End If
       Else
       End If

       If chkhotstamping.Checked = True Then

           strHotStamping = "Hot Stampig"

           If chkhotblock.Checked = True Then
               strBlock = " (Block Ready)+"
           Else
               strBlock = " (New Block)+"
           End If
       Else

       End If


       If chkemboss.Checked = True Then
           strEmboss = " Emboss"
           If chkembossblock.Checked = True Then
               strNew = " (Block Ready)+"
           Else
               strNew = " (New Block)+"
           End If
       Else
       End If

       If chkdiecut.Checked = True Then
           strDieCutting = " Die Cutting"
           If chkdiemould.Checked = True Then
               strMould = " (Mould Ready)+"
           Else
               strMould = " (New Mould)+"
           End If
       Else
       End If

       If chkfold.Checked = True Then
           strFolding = " Folding"
           If chkhand.Checked = True Then
               strHand = " (Hand)+"
           Else
               strHand = " (Machine)+"

           End If
       End If

       If chkcreasing.Checked = True Then
           strCreasing = " Creasing"
       Else

       End If

       If chkglue.Checked = True Then
           strGlue = " Gluing"

           If chkghand.Checked = True Then
               strGhand = " (Hand)+"
           Else
               strGhand = " (Machine)+"
           End If
       End If


       If chkstitch.Checked = True Then
           strStitch = " Center Stitching"
       Else
       End If


       If chklaminate.Checked = True Then
           strLaminate = " Laminate"
           If chkmatt.Checked = True Then
               strMatt = " (Matt Laminate"
               If chkmattfront.Checked = True Then
                   strMattFront = " (Front))+"
               Else
                   strMattFront = " (Back))+"
               End If
           Else
               strMatt = " (Gloss Laminate"
               If chkmattfront.Checked = True Then
                   strGloss = " (Front))+"
               Else
                   strGloss = " (Front))+"

               End If
           End If

       Else
       End If

       If chkstring.Checked = True Then
           strString = " Stringing"
       Else

       End If

       If chkpunch.Checked = True Then
           strPunch = " Punching"
           If chk3mm.Checked = True Then
               str3mm = " (3mm)+"
           Else : str3mm = " (6mm)+"
           End If
       End If

       If chkother.Checked = True Then
           strOther = " Other ( refer remarks )"
       Else
       End If

       If chkkeep.Checked = True Then
           strKeep = "Keep Plate +"
       Else
       End If

       If chkagent.Checked = True Then
           strAgent = " Agent"
       Else
       End If


       If chkinv.Checked = True Then
           myCommand.Parameters.Add("?inv", "1")
       Else
           myCommand.Parameters.Add("?inv", "0")
       End If


       If chkurgent.Checked = True Then
           myCommand.Parameters.Add("?Refer", "Urgent")
       ElseIf chkemerg.Checked = True Then
           myCommand.Parameters.Add("?Refer", "Emergency")
       Else : chkemerg.Checked = True
           myCommand.Parameters.Add("?Refer", txtrefer.Text)

       End If

       If chkcs.Checked = True Then
           myCommand.Parameters.Add("sideCover", "S" & txtcs.Text)
       Else
           myCommand.Parameters.Add("sideCover", "B" & txtcbs.Text)

       End If

       If chkcos.Checked = True Then
           myCommand.Parameters.Add("sideCNT", "S" & txtcos.Text)
       Else
           myCommand.Parameters.Add("sideCNT", "B" & txtcob.Text)

       End If

       If chkloose.Checked = True Then
           myCommand.Parameters.Add("?Qty", txtqty.Text)
       Else
           myCommand.Parameters.Add("?Qty", txtqtyb.Text)
           'myCommand.Parameters.Add("?Set", txtset.Text)
       End If

               Try
           ' Conn.Open()
           myCommand.ExecuteNonQuery()
           txtjobno.Text = strjobno
           txn.Commit()
           MsgBox("Data Saved Successfully!", MsgBoxStyle.Information)

       Catch ex As Exception

           MsgBox("Error = " & ex.Message)

       End Try
   End Sub



Another thing is about my combobox
below is the data that display in combobox

Sql = "SELECT ColorCode FROM colorcode "
           Try
               myCommand.Connection = conn
               myCommand.CommandText = Sql
               myAdapter.SelectCommand = myCommand
               myAdapter.Fill(myData51)
               cbo48.DataSource = myData51
               cbo48.DisplayMember = "colorcode"
               cbo48.ValueMember = "colorcode"
               myAdapter.Dispose()


           Catch myerror As Exception
               MsgBox("There was an error reading from from the database: " & myerror.Message)
           End Try

problem is weh ni din select anything, it still save the data cause the combo box display a data.

THANK YOU FOR ANSWERING MY QUESTION N ALSO HELPING ME,
-------------------------------------------
The text above is a follow-up to ...

-----Question-----
First of all thanks to you for the help.

when i save my data it pop up a message that is       Error = Only byte array and strings can be serialize by MySqlBinary
what is it mean and how do i solve it
thanks
-----Answer-----
pls. paste the code that is causing this error, so I can have a look. Most probably you are trying to use a Command object to save data and parameter's data type are not set correctly.

Answer
OK, checked through the code, didnt find anything wrong, perhaps there is a mismatch between datatype defined in the database and type of value of provided in your code its a good practice to create parameters with strict datatypes defined, e.g. MySqlParameter projidParm = new MySqlParameter("?ProjectId",
MySqlDbType.UInt32,4,"ProjectId") and then add projidParm to command.parameters collection using add method, kindly let me know if that helps.

Regards,
Rizwan

Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.