MySQL and programming

how to insert data into a MySQL database using

Page 1 of 1

0 Replies - 9787 Views - Last Post: 29 October 2008 - 06:34 PM Rate Topic: -----

#1 Ing.KID   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 29-October 08

MySQL and programming

Post icon  Posted 29 October 2008 - 06:34 PM

I'm a beginner in database programming using MySQL but i'm used to sql server. I want to know how to insert data into a mysql database using
I'm trying to save a picture into a database and here is my source code

'putting a picture into a picturebox
If StudentPictureBox.Image Is Nothing Then
			Exit Sub
		End If
		Dim ms As MemoryStream = New MemoryStream

		StudentPictureBox.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)

'converting it
		Dim bytBlobData(ms.Length - 1) As Byte
		ms.Position = 0
		ms.Read(bytBlobData, 0, ms.Length)

		Dim DatabaseParameter As New MySql.Data.MySqlClient.MySqlParameter("@BlobData", MySql.Data.MySqlClient.MySqlDbType.Blob, bytBlobData.Length, ParameterDirection.Input, False, 0, 0, Nothing, DataRowVersion.Current, bytBlobData)

'connecting to the database
		Dim ConnectionString As String = "server=localhost; user id =root;password=root;database=picturedb;"

		Dim QueryString As String = "INSERT INTO blobtest(BlobData) VALUES(@BlobData)"

		myConnection = New MySql.Data.MySqlClient.MySqlConnection
		myConnection.ConnectionString = ConnectionString
		myCommand = New MySql.Data.MySqlClient.MySqlCommand
		myCommand.CommandText = QueryString
		myCommand.Connection = myConnection

		Catch CommandError As MySql.Data.MySqlClient.MySqlException
		End Try

it keeps giving me an error saying that there is something wrong with the command control

Is This A Good Question/Topic? 0
  • +

Page 1 of 1