Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 10th, 2005, 2:54 PM   #1
Arla
Professional Programmer
 
Arla's Avatar
 
Join Date: Mar 2005
Posts: 332
Rep Power: 4 Arla is on a distinguished road
Adding Parameters at creation time for MySqlCommand?

Anyone know if you can add parameters, my current code is

using (MySqlConnection myConnection = new MySqlConnection(ConnectionString))
using (MySqlCommand myInsert = new MySqlCommand(myInsertQuery,myConnection))
{
	myConnection.Open();
	//Add the parameters to the insert query
	myInsert.Parameters.Add(ParamReturnCode);
	myInsert.Parameters.Add(ParamReturnDescription);
	//Data was not found, run the insert query
	myInsert.ExecuteNonQuery();
}

which works fine, but I want to know if I can remove the myInsert.Parameters.Add commands and include them in the using to squash the code down even more (not sure if I want to, but I want to know if it's an option).

Last edited by Arla; Jun 10th, 2005 at 2:55 PM. Reason: Removed some spacing from the code
Arla is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:44 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC