473,395 Members | 1,341 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.

Passing Parameters in a Select Statement

I am trying to get a parameter passed from one page to another in a
QueryString to get inserted into the select statement on the page that is
getting called. If I hard code in a value everything works, but I can't
figure out how to get it to pass in as a parameter. Here is what I have.
The parameter section doesn't work though.

OleDbConnection conn = new
OleDbConnection(ConfigurationSettings.AppSettings["ReportRequestConnectionSt
ring"]);

OleDbDataAdapter da = new OleDbDataAdapter(sqlQuery, conn);

// OleDbParameter myParm = da.SelectCommand.Parameters.Add(ppRequestID,
OleDbType.Numeric, 8, ppRequestID);

conn.Open();

DataSet ds = new DataSet();

da.Fill(ds, "Report");

lblFirstName.Text = (string)ds.Tables[0].Rows[0]["created_by"];
conn.Close();

}
Nov 16 '05 #1
3 2664
How have you defined ppRequestID?

Brian Conway wrote:
I am trying to get a parameter passed from one page to another in a
QueryString to get inserted into the select statement on the page that is
getting called. If I hard code in a value everything works, but I can't
figure out how to get it to pass in as a parameter. Here is what I have.
The parameter section doesn't work though.

OleDbConnection conn = new
OleDbConnection(ConfigurationSettings.AppSettings["ReportRequestConnectionSt
ring"]);

OleDbDataAdapter da = new OleDbDataAdapter(sqlQuery, conn);

// OleDbParameter myParm = da.SelectCommand.Parameters.Add(ppRequestID,
OleDbType.Numeric, 8, ppRequestID);

conn.Open();

DataSet ds = new DataSet();

da.Fill(ds, "Report");

lblFirstName.Text = (string)ds.Tables[0].Rows[0]["created_by"];
conn.Close();

}

Nov 16 '05 #2
Brian Conway <Br**********@qwest.com> wrote:
I am trying to get a parameter passed from one page to another in a
QueryString to get inserted into the select statement on the page that is
getting called. If I hard code in a value everything works, but I can't
figure out how to get it to pass in as a parameter. Here is what I have.
The parameter section doesn't work though.

OleDbConnection conn = new
OleDbConnection(ConfigurationSettings.AppSettings["ReportRequestConnectionSt
ring"]);

OleDbDataAdapter da = new OleDbDataAdapter(sqlQuery, conn);

// OleDbParameter myParm = da.SelectCommand.Parameters.Add(ppRequestID,
OleDbType.Numeric, 8, ppRequestID);

conn.Open();

DataSet ds = new DataSet();

da.Fill(ds, "Report");

lblFirstName.Text = (string)ds.Tables[0].Rows[0]["created_by"];
conn.Close();

}


What value are you trying to set for the parameter? If it's
ppRequestID, then you should be aware that the method you're calling is
using that as the *name* of the parameter, not the value. Use the Value
property of the parameter to set its value.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #3
I figured it out I used

da.SelectCommand.Parameters.Add(ppRequestID, OleDbType.Numeric, 8).Value =
ppRequestID;

and this worked fine.
"Brian Conway" <Br**********@qwest.com> wrote in message
news:uL**************@TK2MSFTNGP11.phx.gbl...
I am trying to get a parameter passed from one page to another in a
QueryString to get inserted into the select statement on the page that is
getting called. If I hard code in a value everything works, but I can't
figure out how to get it to pass in as a parameter. Here is what I have.
The parameter section doesn't work though.

OleDbConnection conn = new
OleDbConnection(ConfigurationSettings.AppSettings["ReportRequestConnectionSt ring"]);

OleDbDataAdapter da = new OleDbDataAdapter(sqlQuery, conn);

// OleDbParameter myParm = da.SelectCommand.Parameters.Add(ppRequestID,
OleDbType.Numeric, 8, ppRequestID);

conn.Open();

DataSet ds = new DataSet();

da.Fill(ds, "Report");

lblFirstName.Text = (string)ds.Tables[0].Rows[0]["created_by"];
conn.Close();

}

Nov 16 '05 #4

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

Similar topics

2
by: zlatko | last post by:
There is a form in an Access Project (.adp, Access front end with SQL Server) for entering data into a table for temporary storing. Then, by clicking a botton, several action stored procedures...
3
by: douglascfast | last post by:
Anyone, Is this possible? I am connecting to a TeraData server via MS SQL 8.0 using the OpenQuery statement. I need to pass a list of ever-changing deal numbers My list of numbers are...
7
by: Harolds | last post by:
The code below worked in VS 2003 & dotnet framework 1.1 but now in VS 2005 the pmID is evaluated to "" instead of what the value is set to: .... xmlItems.Document = pmXML // Add the pmID...
6
by: dharmadam | last post by:
Is it possible to pass a column name or the order of the column name in the DB2 table table function. For example, I want to update the address of a person by passing one of the address column name...
3
by: Zlatko Matić | last post by:
Hello. I know how to call a parameterized stored procedure by using ADODB command object and parameters, but how can I execute the same query using adCmdText instead of adCmdStoredProc? Namely...
1
by: owengoodhew | last post by:
Guys I need your help/Advice... In my Access Database I have a query (lets say qry1) and in this query i have 2 fields for start and end date, which is provided by 2 Get functions. also i...
5
by: glenn | last post by:
Hi folks, The problem I have is that a query string works if hard-coded but if I pass a variable to it, it does not work as shown here. This works: querystring="SELECT * FROM USERS WHERE...
4
by: gordon | last post by:
Hi I have a text boxe that passes its contents to a select command that is used in a where statement - - - WHERE name like '%" + input + "%'. I am concerned that it may be possible for...
11
by: kennthompson | last post by:
Trouble passing mysql table name in php. If I use an existing table name already defined everything works fine as the following script illustrates. <?php function fms_get_info() { $result =...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.