473,395 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to get ADO .NET command with parameters replaced with values

I need to get sql command where parameters are replaced by values.
I tried code below but displayed sql statement contains parameter names,
not actual values.

How to obtain command where parameters are replaced by their values ?

Andrus.

static IDataReader ExecuteReader(string command
, out IDbConnection connection
, CommandBehavior behavior
, params IDbDataParameter[] dataParams)
{
connection = ...
connection.Open();
IDbCommand cmd = new SqlCommand(command, connection as
SqlConnection);
foreach (IDbDataParameter p in dataParams)
cmd.Parameters.Add(p);
// How to display replaced parameter values ?
MessageBox.Show(cmd.CommandText);
return cmd.ExecuteReader(behavior |
CommandBehavior.CloseConnection);
}

Sep 20 '08 #1
1 1645
ADO.NET would never expect to need to do this (since it can pass
parameters, which is safer) - so I doubt there is anything built in.
You will probably need to do your own parse/replace (and escape).

Marc
Sep 21 '08 #2

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

Similar topics

3
by: Bill Cart | last post by:
The oldDb Command does not support Named Parameters. If I am reading them correctly, the docs say that the order of the parameter should match the order they are declared in the Stored Procedure....
2
by: Mark | last post by:
Hi all, a quick ADO.NET question in regards to the command object. What are the advantages (if any) of specifying command parameters when executing a stored procedure over just calling the stored...
5
by: Gene | last post by:
What can I do if I want to get the result using the sql command? for example, the select command is "select Name from Employee where StaffID=10" How to get the "Name"??? dim Name as string and...
3
by: Jerry | last post by:
Well, here is some weirdness. First, I noticed that I have 2 Set keywords (silly me). so I removed the 2nd "Set" but still got a syntax error. Then I removed the Where clause, and now it works...
4
by: David A. Osborn | last post by:
I am having problems with the following insert command: Me.OleDbInsertCommand1.CommandText = "INSERT INTO lutLookup(Type_Name, Work_Code, Work_Code_ID) VALUES ('Payment_ID',' " & _ lstrCode & "...
5
by: mabond | last post by:
Hi VB.NET 2005 Express edition Microsoft Access 2000 (SP-3) Having trouble writing an "insert into" command for a Microsoft table I'm accessing through oledb. I've tried to follow the same...
10
by: Bob | last post by:
Hi, i wrote code for inserting data into a table, but it runs twice. If i remove the line: "comd.ExecuteNonQuery()", then it runs once; but i thought that line was necessary for executing the...
3
by: iKiLL | last post by:
Hi all I am having problems getting my SqlCeDataAdapter to Update the SQL Mobile Data base. i am using C# CF2. I have tried this a number of different ways. Starting with the command builder...
3
by: Sagar | last post by:
Hi. I am working on a project to migrate a web application from 1.1 to 2.0 Within in the DAL of the application, there is a call to below function that builds a command object for later use. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
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
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...

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.