473,503 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

OleDbParameter ,help!!

bby
what's wrong?

string SQL="update D_User set Photo=@Photo where ID=@ID";
OleDbCommand myCommand=new OleDbCommand (SQL,connection);
OleDbParameter myParm1 =new OleDbParameter("@ID",OleDbType.Integer,4);
myParm1.Value = 4
myCommand.Parameters.Add(myParm1);

OleDbParameter myParm2 =new OleDbParameter("@Photo",SqlDbType.Binary);
myParm2.Value = imgdata; //is byte[]
myCommand.Parameters.Add(myParm2);

connection.Open();
myCommand.ExecuteNonQuery(); //wrong line,@Photo is not announceed
connection.Close();
Nov 16 '05 #1
3 12238
Hi bby,

Well, you specify OleDbParameter @Photo but you assign a SqlDbType to it
instead of OleDbType.
Furthermore, in some cases named parameters won't be accepted and you need
to put ? for each parameter in the sql string. The parameters need to be
added in the correct order in this case.

--
Happy Coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #2
Hi,

OleDb accepts ? as parameter instead of @name.
"update D_User set Photo=? where ID=?"

Then add OleDbParameters to command in the same order as they appear in the
statement.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
SLODUG - Slovene Developer Users Group
www.rthand.com

"bby" <li***@0536.net> wrote in message
news:uH**************@tk2msftngp13.phx.gbl...
what's wrong?

string SQL="update D_User set Photo=@Photo where ID=@ID";
OleDbCommand myCommand=new OleDbCommand (SQL,connection);
OleDbParameter myParm1 =new OleDbParameter("@ID",OleDbType.Integer,4);
myParm1.Value = 4
myCommand.Parameters.Add(myParm1);

OleDbParameter myParm2 =new OleDbParameter("@Photo",SqlDbType.Binary);
myParm2.Value = imgdata; //is byte[]
myCommand.Parameters.Add(myParm2);

connection.Open();
myCommand.ExecuteNonQuery(); //wrong line,@Photo is not announceed
connection.Close();

Nov 16 '05 #3
bby
thanks

i have raveled out!
but only one Paremeter.

-------------------------
string SQL="update D_Table set Photo=? where ID="+Rid;
OleDbCommand myCommand=new OleDbCommand (SQL,connection);

OleDbParameter myParm =new OleDbParameter("@Photo",OleDbType.Binary);
myParm.Value = imgdata;
myCommand.Parameters.Add(myParm);
connection.Open();
myCommand.ExecuteNonQuery();
connection.Close();

-------------------------
maybe is SqlClient Model is:

string SQL="update D_Table set Photo=@Photo where ID="+Rid;
SqlCommand myCommand=new SqlCommand (SQL,connection);
SqlParameter myParm =new SqlParameter("@Photo",SqlDbType.Image);
myParm.Value = imgdata;
myCommand.Parameters.Add(myParm);
connection.Open();
myCommand.ExecuteNonQuery();
connection.Close();

am i right?
-------------------------
"bby" <li***@0536.net> дÈëÏûÏ¢
news:uH**************@tk2msftngp13.phx.gbl...
what's wrong?

string SQL="update D_User set Photo=@Photo where ID=@ID";
OleDbCommand myCommand=new OleDbCommand (SQL,connection);
OleDbParameter myParm1 =new OleDbParameter("@ID",OleDbType.Integer,4);
myParm1.Value = 4
myCommand.Parameters.Add(myParm1);

OleDbParameter myParm2 =new OleDbParameter("@Photo",SqlDbType.Binary);
myParm2.Value = imgdata; //is byte[]
myCommand.Parameters.Add(myParm2);

connection.Open();
myCommand.ExecuteNonQuery(); //wrong line,@Photo is not announceed
connection.Close();

Nov 16 '05 #4

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

Similar topics

3
1380
by: Brian Conway | last post by:
Can anyone give me a quick little break down of what I would need to do to insert information into a database onClick of and Submit button? I am new to all of this and have done it with datagrids,...
1
3542
by: Steven K | last post by:
Hello, I am calling a SQL Server 2K parameter query with the following: Dim spWebDocGroup As OleDb.OleDbDataReader Dim prmWebDocGroup As OleDbParameter Dim cmdWebDocGroup As New...
4
2647
by: DOTNET | last post by:
Hi, Anybody help me regarding this error: I am assigning the values to the session variables when the button is clicked and passing these session variables to the next page and when I am...
3
1561
by: Shapper | last post by:
Hello, I need to add a new record to an ACCESS database. I get the error: Syntax error in INSERT INTO statement. I have no idea what am I doing wrong. This is my code: ' Set Connection...
3
3426
by: Shapper | last post by:
Hello, I have created 3 functions to insert, update and delete an Access database record. The Insert and the Delete code are working fine. The update is not. I checked and my database has all...
1
1074
by: MDB | last post by:
Hello all, I know this may not be the correct group but was hoping someone could help anyway. I have a stored procedure that is not returning the correct information. For some reason it is not...
2
2941
by: DC | last post by:
The Code <%@ import namespace="System" %> <%@ import namespace="System.Web" %> <%@ import namespace="System.Web.UI" %> <%@ import namespace="System.Web.UI.HtmlControls" %> <%@ import...
0
3544
by: DC | last post by:
The problem I'm using the .NET GridView and FormView objects for the first time and im getting the error "An OleDbParameter with ParameterName '@ID' is not contained by this...
4
8534
by: pankajsingh5k | last post by:
Hi guys, These question is for all the experts... Please help me before my brain explodes The problem is again with the formview control.. I have a formview and i have to use it that...
0
7076
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...
0
7274
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7323
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...
0
7453
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5005
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...
0
4670
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...
0
3162
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...
1
732
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
377
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.