MySQL Forums
Forum List  »  Newbie

using parameters with MySql
Posted by: Jon Tipps
Date: August 01, 2005 03:14PM

I'm developing in .net and using odbc connection with mysql.
I have look every where for information on adding Parameters to a MySql query and can't find anything??
Can you even have parameters in MySql??

I can connect fine and run a select query but when i try to insert a new row and make up a parameter collection it's like it doesn't even see them.

Dim Conn As New System.Data.Odbc.OdbcConnection("Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=blablabl;uid=asdfas;pwd=yasdfas;option=3"

Dim myCommand As New OdbcCommand("INSERT INTO [rafterginfo] (" & _
"[CatID], [abbi],[sire],[dam],[dob],[description],[ProdID], [LG_img_name], [LG_img_data], [LG_img_contenttype], [SM_img_name], [SM_img_data], [SM_img_contenttype] )" & _
"VALUES (@CatID, @Abbi, @Sire, @Dam, @DOB, @Description, @ProdID, @img_name, @img_data, @img_contenttype, @img_name2, @img_data2, @img_contenttype2)", Conn)
Dim Param0 As New OdbcParameter("@ProdID", OdbcType.NVarChar, 50)
Dim Abbi1 As New OdbcParameter("@Abbi", OdbcType.NVarChar, 50)
Dim Sire1 As New OdbcParameter("@Sire", OdbcType.NVarChar, 150)
Dim Dam1 As New OdbcParameter("@Dam", OdbcType.NVarChar, 150)
Dim DOB1 As New OdbcParameter("@DOB", OdbcType.NVarChar, 50)
Dim Description1 As New OdbcParameter("@Description", OdbcType.NVarChar, 250)
Dim Param1 As New OdbcParameter("@img_name", OdbcType.VarChar, 50)
Dim Param2 As New OdbcParameter("@img_data", OdbcType.Image)
Dim Param3 As New OdbcParameter("@img_contenttype", OdbcType.VarChar, 50)
Dim Param4 As New OdbcParameter("@img_name2", OdbcType.VarChar, 50)
Dim Param5 As New OdbcParameter("@img_data2", OdbcType.Image)
Dim Param6 As New OdbcParameter("@img_contenttype2", OdbcType.VarChar, 50)
Dim CatID As New OdbcParameter("@CatID", OdbcType.Int, 4)

Param0.Value = txtProdID.Text
Abbi1.Value = ABBI.Text
Sire1.Value = Sire.Text
Dam1.Value = Dam.Text
DOB1.Value = DOB.Text
Description1.Value = Des.Text


Param1.Value = imgName
Param2.Value = imgbin
Param3.Value = imgContentType
Param4.Value = imgName2
Param5.Value = imgbin2
Param6.Value = imgContentType2
CatID.Value = DropDownList1.SelectedValue

myCommand.Parameters.Add(Param0)
myCommand.Parameters.Add(Abbi1)
myCommand.Parameters.Add(Sire1)
myCommand.Parameters.Add(Dam1)
myCommand.Parameters.Add(DOB1)
myCommand.Parameters.Add(Description1)
myCommand.Parameters.Add(Param1)
myCommand.Parameters.Add(Param2)
myCommand.Parameters.Add(Param3)
myCommand.Parameters.Add(Param4)
myCommand.Parameters.Add(Param5)
myCommand.Parameters.Add(Param6)
myCommand.Parameters.Add(CatID)

Conn.Open()
SaveImageToDB = myCommand.ExecuteNonQuery()
Conn.Close()

Please Help!

Options: ReplyQuote


Subject
Written By
Posted
using parameters with MySql
August 01, 2005 03:14PM
August 01, 2005 06:17PM


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.