473,765 Members | 2,058 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cannot add stored procedure with parameterized query

I'm fairly new to this so hopefully it is a dumb mistake...

I need to create a simple stored procedure along the lines of:

delimiter //
CREATE DEFINER='root'@ 'localhost' PROCEDURE Insertuser()
BEGIN
insert into user (firstname,last name) values (@fn, @ln);
END;
//

that I can then use with the code:

MySqlConnection oConn = new
MySqlConnection (ConfigurationM anager.AppSetti ngs["MySqlConn"].ToString());
oConn.Open();
MySqlCommand oCommand = oConn.CreateCom mand();
oCommand.Comman dType = CommandType.Tex t;
oCommand.Comman dText = "INSERT into user (firstname,last name)
VALUES (@fn,@ln)";

MySqlParameter p0 = new MySqlParameter( "@fn", TextBox2.Text);
oCommand.Parame ters.Add(p0);
MySqlParameter p1 = new MySqlParameter( "@ln", TextBox3.Text);
oCommand.Parame ters.Add(p1);

oCommand.Execut eNonQuery();
oConn.Close();

However running this sproc and code with MySQL just puts in a blank
record into the table :-(

So...I read that with MySQL you need to use the ? character in place of
the @ character for parameterized queries.
I did this replacement and the code ran fine but ONLY if I had the
query set up as CommandType text (as in the example above).

The PROBLEM is that when I try to create the sproc using the MySQL
command line tool with:

delimiter //
CREATE DEFINER='root'@ 'localhost' PROCEDURE Insertuser()
BEGIN
insert into user (firstname,last name) values (?fn, ?ln);
END;
//

It gives me a syntax error - presumably due to the ? characters!

Any advice on where I am going wrong gladly received!

Jul 26 '06 #1
0 3624

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1551
by: Andrew J Durstewitz | last post by:
Hi! I'm not sure if you can do this but what I want to do it execute a stored procedure but query it with dynamic ASP data. Basically, exex StoredProc where id = 2 I am using a set of dynamic data and I truly belive looping trought the dataset would be too much overhead on the server.
2
10391
by: Begoña | last post by:
in my java application I've made a call to this stored procedure CREATE procedure pruebaICM @pANI varchar(20), @pTABLA varchar(20), @pInsert varchar(500), @pUpdate varchar(1000), @pFLAG varchar(1), @pResultado int OUTPUT
2
3413
by: Daniel | last post by:
hi ng, i am newbie to sqlserver and my problem seems simple, but i didn't find information about it: How can i display the RETURN @x value of a stored procedure in the sql analyzer of the sqlserver? thanks a lot, d
10
3745
by: Thomas R. Hummel | last post by:
I have a stored procedure that suddenly started performing horribly. The query plan didn't look right to me, so I copy/pasted the code and ran it (it's a single SELECT statement). That ran pretty well and used a query plan that made sense. Now, I know what you're all thinking... stored procedures have to optimize for variable parameters, etc. Here's what I've tried to fix the issue: 1. Recompiled the stored procedure 2. Created a new,...
1
1651
by: Ed Murphy | last post by:
One of my clients has a stored procedure on their secondary server that copies a bunch of data from the production server. (Replication will break the accounting software, according to its authors. The production server generates a nightly full backup, so if the secondary can be scripted to do a nightly restore from that same file, then that would probably be a Big Win.) Anyway, if I execute the stored procedure from Query Analyzer, it...
3
6871
by: comp_databases_ms-sqlserver | last post by:
This post is related to SQL server 2000 and SQL Server 2005 all editions. Many of my stored procedures create temporary tables in the code. I want to find a way to find the query plan for these procs Repro --*********************************** use pubs go CREATE PROCEDURE Test @percentage int
3
4171
by: getajaysharma | last post by:
Hi All I am having problem. i want to compare the results of Stored Procedure & SQL Query. Can any one tell me how can i achive this. Please expalin with example. Regards Ajay Sharma
1
1369
by: pankajit09 | last post by:
The below is an Oracle Stored procedure --> create or replace function search_in_table( owner varchar2, table_name varchar2, search_string varchar2)
1
1260
by: pankajit09 | last post by:
The below is an Oracle Stored procedure --> create or replace function search_in_table( owner varchar2, table_name varchar2, search_string varchar2)
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9399
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9957
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7379
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5276
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3924
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.