473,385 Members | 1,620 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,385 software developers and data experts.

how i can get parameter value from data base in c#

i have a store procedure need to get the date from the data base help me please with this. i know something missing in the code right here:

da.SelectCommand.Parameters.Add(new SqlParameter("@Datecreated",SqlDbType.DateTime));




Expand|Select|Wrap|Line Numbers
  1.  
  2.     private void Page_Load(object sender, System.EventArgs e)
  3.         {
  4.             // Put user code to initialize the page here
  5.  
  6.             string employeenominationid;
  7.             employeenominationid=Request.QueryString ["employeenominationid"];
  8.  
  9.  
  10.          SqlConnection oConn=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["oConn"]);
  11.  
  12.             SqlDataAdapter da=new SqlDataAdapter("up_reason",oConn);
  13.  
  14.             DataSet ds=new DataSet(); 
  15.  
  16.             da.SelectCommand.CommandType=CommandType.StoredProcedure;
  17.  
  18.             da.SelectCommand.Parameters.Add(new SqlParameter("@employeenominationid",employeenominationid));
  19.             //SqlParameter obj=new SqlParameter("@EmployeeNominationid",SqlDbType.Int);
  20.             da.SelectCommand.Parameters.Add(new SqlParameter("@Datecreated",SqlDbType.DateTime));
  21.  
  22.             oConn.Open();
  23.             da.SelectCommand.ExecuteNonQuery();
  24.             oConn.Close();
  25.  
  26.             da.Fill(ds) ;
  27.  
  28.             this.garidreason.DataSource=ds;
  29.             this.DataBind();
  30.  
  31.             da.Dispose(); 
  32. }
  33.  
  34.  
  35.  
Aug 24 '07 #1
3 2224
weaknessforcats
9,208 Expert Mod 8TB
I am moving this to the .NET forum.
Aug 25 '07 #2
kenobewan
4,871 Expert 4TB
How do you know its not working? Do you get any errors? Have you tried using a try catch block?
Aug 26 '07 #3
do you want the date value retrieved from the database ie via SP.
If this is ur requirement have you declared the data parameter as out in SP. If yes then u have to specify the parameter direction as output in .cs file
Aug 26 '07 #4

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

Similar topics

0
by: K Altsj? | last post by:
If passing a DataSet to a web method for update using ADO.NET and the update fails, the parameter list may get corrupt. The following code example consists of a Web Service and a consumer console...
5
by: Dan =o\) | last post by:
given this brief scenario, is this possible somehow? class A { public SomeMethod() { } }
7
by: moondaddy | last post by:
I have a user control being used instead of a frame page. when the user clicks on a menu item I need to send the ID (integer value) of that menu as a parameter in the postback of the user control...
7
by: Richard Grant | last post by:
Hi. In c/C++ i can pass the address of a subroutine to another subroutine as an actual parameter How do I do that in VB .NET What should be the syntax for a parameter to receive the address of a...
13
by: dbuchanan | last post by:
Hello, Here is the error message; ---------------------------- Exception Message: ForeignKeyConstraint Lkp_tbl040Cmpt_lkp302SensorType requires the child key values (5) to exist in the...
8
by: Raider | last post by:
I have simple class hierarchy (without multiple inheritance): class Base {}; class Derived : public Base {}; class DeepDerived : public Derived {}; // ... a lot of types Is it ok to cast...
8
by: Alec MacLean | last post by:
Hi, I'm using the DAAB Ent Lib (Jan 2006) for .NET 2.0, with VS 2005 Pro. My project is a Web app project (using the WAP add in). Background: I'm creating a survey system for our company, for...
13
by: Jack | last post by:
I have a class called "Base". This class has a protected member variable "m_base" which can be retrieved using the public member function "GetBaseMember". "m_base" is initialized to "1" and is...
0
by: jans78 | last post by:
Appreciate if you all can help me to solve my Crystal Report problems First, I create some parameters and one of the parameters is Date. I set the parameter for the date is String. For example :...
7
by: jamesclose | last post by:
My problem is this (apologies if this is a little long ... hang in there): I can define a function in VB.NET with optional parameters that wraps a SQL procedure: Sub Test(Optional ByVal Arg1...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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...

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.