473,466 Members | 1,439 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

ERROR : The OleDbParameterCollection only accepts non-null OleDbParameter type objec

1 New Member
public int ExecuteNonQuery(string query, params OleDbParameter[] parameters)
{
OleDbConnection cnn = new OleDbConnection(strConnectionString);
OleDbCommand cmd = new OleDbCommand(query, cnn);
if (query.StartsWith("INSERT") | query.StartsWith("insert") | query.StartsWith("UPDATE") | query.StartsWith("update") | query.StartsWith("DELETE") | query.StartsWith("delete"))
{
cmd.CommandType = CommandType.Text;
}
else
{
cmd.CommandType = CommandType.StoredProcedure;
}
for (int i = 0; i <= parameters.Length - 1; i++)
{


cmd.Parameters.Add(parameters[i]);

}
cnn.Open();
int retval = cmd.ExecuteNonQuery();
cnn.Close();
return retval;
}

TIHS IS CODE PLEASE HELP VERY URGENT
Apr 28 '07 #1
1 1858
shweta123
692 Recognized Expert Contributor
Hi,

Can you specify more details about your code and the Line No where you are getting the error?
Are you executing the stored procedure or simple Sql query through the function?
If it is a Sql query and you are using any placehoders for that, see if this Thread helps you.
Apr 29 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Alex Vinokur | last post by:
Hi, GNU g++ 3.4 detects an error in code below. What is wrong here? --------- foo.cpp : BEGIN --------- template <typename T> struct Foo {
6
by: WindAndWaves | last post by:
Hi Gurus The page below has a strange error. It seems to be working very well, just when you enter 8 or 9 for day, month or year then you get an error. I really have no idea where that is...
4
by: interpim | last post by:
ok the function is supposed to accept only non-negative integers... but it still accepts letters input through the function. Such as '23e' still passes through. I tried to use isalpha in the or...
3
by: prasi | last post by:
hi all, I have executed the following program, I was expecting some errors in the program but it didn't give any ERRORS!!!!!!!!!!!!!!!!!!!!!!!!!!! please can anybody explain me ?...
3
by: Stephen | last post by:
Hi, I am trying to update a record in the DB and i am using OLEDB command and connection. I get this error while updating. Error inserting data: System.Data.OleDb.OleDbException: Syntax error...
5
by: PLS | last post by:
I'm converting some C++ code to VC++ 2005 in native (non-managed) mode. This code doesn't use ATL, but codes the COM mechanisms directly. It has a class which is the equivalent of ATL's...
35
by: jeffc226 | last post by:
I'm interested in an idiom for handling errors in functions without using traditional nested ifs, because I think that can be very awkward and difficult to maintain, when the number of error checks...
11
by: u.int.32.t | last post by:
Is there a way to make a single template function that will accept both const and non-const parameter types by reference without making a copy? For example, I can write this which will accept...
6
by: smmk25 | last post by:
Before I state the problem, I just want to let the readers know, I am knew to C++\CLI and interop so please forgive any newbie questions. I have a huge C library which I want to be able to use in...
1
by: chris fellows | last post by:
I have a C# webservice with a web method that accepts a string parameter that contains encrypted data. For some parameter values with non-alphanumeric values then the web method fails with an HTTP...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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
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
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...
1
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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
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...

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.