************************i dont want a connection to be created since i using ado entity framework NorthwindEntities db= new NorthwindEntities();*********
// 1. declare command object with parameter
SqlCommand cmd = new SqlCommand(
"insert into Customers (name) values (@name)", conn);
***********************//am using db. ExecuteStoreCommand("insert into Customers (name) values (@name)";)*************************************
// 2. define parameters used in command object
SqlParameter param = new SqlParameter();
param.ParameterName = "@name";
param.Value = inputCity;
*************************well i can use the above
// 3. add new parameter to command object
cmd.Parameters.Add(param);
???????????????????????am not using cmd .........how to add parameter
Rockin2009
Member
71 Points
179 Posts
how to change cmd.Parameters.Add("@pic", bytePic) to store commands
Nov 18, 2010 08:41 AM|LINK
SqlCommand cmd = new SqlCommand("insert into ImageTable (pic) values (@pic)", new SqlConnection(connectionString));
i have used the store command
string esqlQuery = "insert into [Test] (Name,image) values('" + filePath + "',@image)";//its working fine with oly Name
db.ExecuteStoreCommand(esqlQuery);
but i dont how to use
cmd.Parameters.Add("@pic", bytePic);
sansan
All-Star
53942 Points
8147 Posts
Re: how to change cmd.Parameters.Add("@pic", bytePic) to store commands
Nov 18, 2010 03:40 PM|LINK
Check this sample
http://www.csharp-station.com/Tutorials/AdoDotNet/Lesson06.aspx
If your parameter is an image, you need to pass the byte array from the image file/upload control(if you are using file upload control).
manoj0682
Star
8479 Points
1499 Posts
Re: how to change cmd.Parameters.Add("@pic", bytePic) to store commands
Nov 18, 2010 03:47 PM|LINK
check below link
Insert Image into Folder and Database
Manoj Karkera
Rockin2009
Member
71 Points
179 Posts
Re: how to change cmd.Parameters.Add("@pic", bytePic) to store commands
Nov 28, 2010 02:31 PM|LINK
conn = new
SqlConnection("Server=(local);DataBase=Northwind;Integrated Security=SSPI");
conn.Open();//
************************i dont want a connection to be created since i using ado entity framework NorthwindEntities db= new NorthwindEntities();*********
// 1. declare command object with parameter
SqlCommand cmd = new SqlCommand(
"insert into Customers (name) values (@name)", conn);
***********************//am using db. ExecuteStoreCommand("insert into Customers (name) values (@name)";)*************************************
// 2. define parameters used in command object
SqlParameter param = new SqlParameter();
param.ParameterName = "@name";
param.Value = inputCity;
*************************well i can use the above
// 3. add new parameter to command object
cmd.Parameters.Add(param);
???????????????????????am not using cmd .........how to add parameter
mudassarkhan
All-Star
78956 Points
13402 Posts
MVP
Re: how to change cmd.Parameters.Add("@pic", bytePic) to store commands
Nov 28, 2010 03:14 PM|LINK
Refer here
http://www.aspsnippets.com/Articles/Save-and-Retrieve-Files-from-SQL-Server-Database-using-ASP.Net.aspx
I have explained how to insert binary data in database
Contact me
Rockin2009
Member
71 Points
179 Posts
Re: how to change cmd.Parameters.Add("@pic", bytePic) to store commands
Nov 28, 2010 03:41 PM|LINK
Thats not the question ...and the subject....how to add parameter without using new sqlcommand...am mentioning above...am usin execute store command