Re: Only byte arrays and strings can be serialized by MySqlBinary
Posted by:
jon dur
Date: January 01, 2007 10:34AM
Please help me. I am using Visual basic 2005 with mysql 5.0(with mysql administrator, .net connector etc) but i can't insert values in the database.
here is my codes:
******************************************************************
<%@ Page Language="VB" debug="true" %>
<%@ Import Namespace = "System.Data" %>
<%@ Import Namespace = "MySql.Data.MySqlClient" %>
<%@ Import Namespace = "MySql.Data.MySqlCommand" %>
<%@ Import Namespace = "MySql.Data.MySqlParameterCollection" %>
<Script Runat="Server">
Sub Button_Click(ByVal s As Object, ByVal e As EventArgs)
Dim intfield As String
Dim textfield As String
Dim datefield As String
Insert(intfield, textfield, datefield)
End Sub
Public Function Insert(ByVal intfield As String, ByVal textfield As String, ByVal datefield As String) As Boolean
Dim myConnection As MySqlConnection
'Dim myDataAdapter As MySqlDataAdapter
'Dim myDataSet As DataSet
Dim cmdInsert As MySqlCommand
Dim strSQL As String
'Dim iRecordCount As Integer
myConnection = New MySqlConnection("server=localhost; user id=15secs; password=password; database=mydatabase; pooling=false;")
strSQL = "Insert into mytable ( intfield) Values ( ?intfield,?textfield,?datefield)"
cmdInsert = New MySqlCommand(strSQL, myConnection)
cmdInsert.Parameters.Add("?intfield", txtintfield)
cmdInsert.Parameters.Add("?textfield", txttextfield)
cmdInsert.Parameters.Add("?datefield", txtdatefield)
myConnection.Open()
cmdInsert.ExecuteNonQuery()
myConnection.Close()
Return True
End Function
</Script>
<html>
<head><title>SqlFormInsert.aspx</title></head>
<body>
<form Runat="Server">
<h2>Add New Product</h2>
<b>Product Name:</b>
<br>
<asp:TextBox
ID="txtintfield"
Runat="Server" />
<p>
<b>Unit Price:</b>
<br>
<asp:TextBox
ID="txttextfield"
Runat="Server" />
<p>
<br>
<asp:TextBox
ID="txtdatefield"
Runat="Server" />
<p>
<asp:Button
Text="Add!"
OnClick="Button_Click"
Runat="Server" />
</form>
</body>
</html>
**********************************************************************
errrors obtained :
MySql.Data.MySqlClient.MySqlException: Only byte arrays and strings can be serialized by MySqlBinary
*********************************************************
Please can anyone help me with that, i am new in this field and stuck with this problem for almost 2 months..
please send me a sample of insert codes.!!!!!
Help!!!!
Best regards,
Jo
PS: still Happy new year!!!
Subject
Written By
Posted
September 14, 2006 11:16PM
September 15, 2006 02:32AM
Re: Only byte arrays and strings can be serialized by MySqlBinary
January 01, 2007 10:34AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.