473,473 Members | 2,032 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problem with prepared statements of DB2 using OLEDB

NS
Hi,

I am trying to execute a prepare statement using oledb provider for
DB2. The command.Prepare() statement is giving me an exception

" No error information available: DB_E_NOCOMMAND(0x80040E0C)."

My code is very simple and is working with other oledb provider, like
SQL Server and oracle.

The code is
OleDbConnection rConn = new
OleDbConnection("Provider=IBMDADB2.1;Persist Security Info=False;Data
Source=SAMPLE;Mode=ReadWrite;User id=db2admin;Password=db2admin;");
rConn.Open();
System.Data.OleDb.OleDbCommand command = new
System.Data.OleDb.OleDbCommand(null, rConn);

// Create and prepare an SQL statement.
command.CommandText = "insert into Department
(DEPTNO,DEPTNAME,MGRNO,ADMRDEPT,LOCATION) values (?,?,?,?,?)" ;

command.Parameters.Clear();
System.Data.OleDb.OleDbParameter pp = new
OleDbParameter("@tt",System.Data.OleDb.OleDbType.C har);
pp.Value = "A12";
command.Parameters.Add(pp);
System.Data.OleDb.OleDbParameter pp1 = new
OleDbParameter("@name",System.Data.OleDb.OleDbType .VarChar,29);
pp1.Value = "myFirstDept";
command.Parameters.Add(pp1);
System.Data.OleDb.OleDbParameter pp2 = new
OleDbParameter("@mgr",System.Data.OleDb.OleDbType. Char);
pp2.Value = "ABC";
command.Parameters.Add(pp2);
System.Data.OleDb.OleDbParameter pp3 = new
OleDbParameter("@adm",System.Data.OleDb.OleDbType. Char);
pp3.Value = "aa";
command.Parameters.Add(pp3);
System.Data.OleDb.OleDbParameter pp4 = new
OleDbParameter("@loc",System.Data.OleDb.OleDbType. Char);
pp4.Value ="San";
command.Parameters.Add(pp4);

command.ExecuteNonQuery();

rConn.Close();
I have tried all possible things that I can find on the internet.
Kindly let me know what am I missing...

Any help in this regard will be great.

Thanx,
NS

Nov 12 '05 #1
4 7781
NS
I missed a line....

command.Prepare();

before command.ExecuteNonQuery();

I even tried running the same code without Prepare(), but still the
same error.

I posted the message on .NET oledb forum and they replied that it might
be a problem with DB2 oledb provider.

Does any of u faced such a problem with prepared statements of DB2
oledb provider?

Nov 12 '05 #2
What version of DB2 are you using? The OLE DB driver was a catastrophe in
7.2, was better in 8.1, and is OK (even if not good) in 8.2. If you have DB2
7.2, I recommend you use the MS OLE DB over ODBC driver, with the DB2 ODBC
driver. With 8.x you should be OK.

"NS" <ne**********@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
I missed a line....

command.Prepare();

before command.ExecuteNonQuery();

I even tried running the same code without Prepare(), but still the
same error.

I posted the message on .NET oledb forum and they replied that it might
be a problem with DB2 oledb provider.

Does any of u faced such a problem with prepared statements of DB2
oledb provider?

Nov 12 '05 #3
NS
Thanx Mark for ur reply.

I am using DB2 version 8. But still getting the same problem with
prepared statements.

I am new to DB2, can u please tell me what is the connection string for
using MS OLE DB over ODBC driver, with the DB2 ODBC driver. Also do I
need to download something for it??

Thanx,
NS

Nov 12 '05 #4
You already have all the parts in MDAC and the DB2 client. The easiest way
to figure out a connection string is to create a DSN via the GUI, then read
what it does for you. Otherwise, it's all in the DB2 and MDAC documentation.

Personally, I would recommend against hard coding connection strings anyway,
especially as you can use AD to publish the whole connectivity issue. I'd
also go Kerberos, as hardcoding passwords in a connection string, as you
did, is asking for trouble.

"NS" <ne**********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Thanx Mark for ur reply.

I am using DB2 version 8. But still getting the same problem with
prepared statements.

I am new to DB2, can u please tell me what is the connection string for
using MS OLE DB over ODBC driver, with the DB2 ODBC driver. Also do I
need to download something for it??

Thanx,
NS

Nov 12 '05 #5

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

Similar topics

1
by: Mark | last post by:
hello! mysqli in PHP5 comes with prepared statements functionality. However, without persistent connections or connection pooling in this code library, one has to ask: why bother? are...
0
by: David.Tymon | last post by:
>Description: MySQL v4.1.0-alpha only allows a client to prepare a maximum of 254 statements. On the 255th mysql_prepare() call, a failure is returned with no information returned by...
1
by: Tom D | last post by:
I'm rewriting a database interface that our company currently has. Currently it's using the Pear::DB interface, but we found that that was introducing a bit too much overhead. I'm rewriting the...
2
by: ojorus | last post by:
Hi! Some questions regarding the mysqli-extension (php5) 1) Prepared statements: If I understand things right, prepared statements will give better performance if you make several similar...
2
by: Pugi! | last post by:
It is by accident that I noticed that I forgot to use mysql_real_escape_string in part of my webapp. I tested input with following text : Hélène 51°56'12'' http://www.mysite.org/folder 3 functions...
1
by: lazukars | last post by:
I have done a good amount of research on prepared statements in php. The problem is that I have found various examples on how to select and insert information into a Mysql database. I want to make...
0
by: lazukars | last post by:
I am building some code with msqli prepared statements via. The code will be used for a form that will send data to a MySql database. What I would like to know is how secure are prepared...
6
by: Gordon | last post by:
I want to search a folder structure represented in a database. I'm using the ID and Parent columns model, and would like to be able to search a folder's subfolders as well as teh folder itself. ...
2
by: mnarewec | last post by:
I would like to execute multiple SQL Statement using OleDB command but its coming up with error " Characters found after end of statement" Below is my pieces of code. Public Class DalOleDb...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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,...
1
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.