How get one value from one column from sqldatasource?

Hi, a few days i am trying to get one value from one column from database and put in one local variable (INT)........


i trying this:

protected void SqlDataSource1_Load(object sender, EventArgs e)protected void SqlDataSource1_Load(object sender, EventArgs e)



Int32 status;


"SELECT status FROM users WHERE Username='" + Membership.GetUser() + "'";status = SqlDataSource1.Select(DataSourceSelectArguments.Empty);



"status" is the variable in question....


anyone can help me?


8/2/2007 9:14:27 PM 29906 articles. 0 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 47

Prefered way would be ExcuteScalar

protected void ExecuteScalarDemo ( ) {
// specify the data source
SqlConnection myConn = new SqlConnection (
"server=( local )\\NetSDK; trusted_connection=yes; database=pubs" );

// define the command query
string query = "SELECT status FROM users WHERE Username='" + Membership.GetUser() + "'";

// initialize command object with the specified query and connection
SqlCommand myCommand = new SqlCommand ( query, myConn );

// open the data connection
myConn.Open ( );

// execute the command
int status = ( int ) myCommand.ExecuteScalar ( );

// close the data connection
myConn.Close ( );


Farooq Kaiser, MCTS, MCP
Please Mark As Answer if my answer helped you.
8/2/2007 9:47:00 PM

Similar Artilces:

SQL: mutiple rows one column to multiple columns one row
In InfoMaker SQL can you take a table with multiple rows for the same key and take a column from the rows and create mutiple columns with one report line with the key(no duplicate keys) on a report? For example Table books (key) (book title) 123 misery 123 titanic 123 roots 456 war 456 1984 456 giant The report I need would look like this Key title1 title2 title 3 123 misery titanic roots 456 war 1984 giant Thanks in advance. -- Kaye Hendry HealthInsight ...

INSERT INTO command (two columns) with one fixed value, one string with several values
I have a string with values value1,value2, value3, value(n) which I would like to append to my table. In the second column of my table I have a parameter which stays the same, so I end up with (if the parameter value is "123456") Column 1   |         Column 2 123456      |         Value1 123456      |         Value2 123456      |      &...

How to get fields from a SQL DB one by one
------=_NextPart_000_00D1_01C39315.7F792D30 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, Can any one tell me How to get fields from a SQL Database. I need to get each field separately. Thanks in advance, Ramakrishna.S ------=_NextPart_000_00D1_01C39315.7F792D30-- this (the method below) is database dependent, i use it with postgres: sub getFieldNames { my $dbh = new DBI(...) my $sth = $dbh->prepare("SELECT * FROM $table WHERE 1=0"); $sth->execute; # # Get all the fi...

Ways to get a mapping of values versus keys in a hash where there is one-to-one mapping between the keys and the values !
------=_Part_6250_27861417.1227632496175 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi all, I recently had one requirement where I needed to get the key in a hash on the basis of supplied value. There is one additional information that there is one to one mapping between the keys and the values. I was able to do that by defining a extra array and hash variables as shown in the program below but I feel this approach will not work for all scenarios like :- 1. When the value of a particular key is undef in the ori...

SQL,Make Multiple values for multiple columns into one column separated by comma
Hi, I'm getting the result as this Name       Class       Subject------------------------------------------Anju         10             MathsAnju         10             Physics How to write the query to get the result like this Name       Class       Subjects------------...

One to Many to One to One
I have a kinda small problem; if someone could help me that' would be niceTo keep things simplier, allow me to give the following exampleI have two tables one-to-many relationship,table1: itemtable2: itemhistoryitem has many itemhistorybasically i want retrieve all the records in 'item' sorted by 'name', along with ONE "latest" itemhistory" (date). If there aren't any historyhistory for a particular 'item', just allow null values. egcreate table #item(itemid int, name varchar(10))create table #itemhistory(itemhistoryid int, itemid int, date...

One-to-One or Many-to-One?
 Hi Friends,I've made huge database for Learning Management Systems which has around 30 - 40 tables.I was checking all the relationships between tables and everything seems fine and well defined. But, it's 4:22 AM here and I'm bit sleepy but I was thinking which of the following relationship is true between the following two tables:Table1: tbl_users (PK username, password, name, surname, email, address1, address2, phNumb)Table2: tbl_testAttempts (PK Id, username, testId, attempt, timeStart, timeEnd)As you see, the Primary key of tbl_users is foreign key in tbl_testAttempts. ...

Casting of IDVault.get({dn}, 'group', 'Member') to handle zero, one or more than one values in a multi-valued attribute
- - - - - - - - - - - - - - - - - - - - - - - - I wonder if anyone can recommend a foolproof method of casting IDVault.get({dn}, 'group', 'Member') so that the result can be easily treated as an array irrespective of how many values there are in the multi-valued attribute. - - - - - - - - - - - - - - - - - - - - - - - - Background to this question 1) In an activity's Data Item Mapping Source Expression I have the following expression: <<theMembers = IDVault.get('CN=myGroup,o=ACME', 'group', 'Member');>> But I fin...

Trying to enter more than one selected value into one column in the database.
Hi i am trying to enter more than one value into my constructor field in my database, at the moment when the values are entered into the database through the front end, they appear in the database as seperate records however they have the same ID,  the only thing that changes is are the data in the fields which i want in just one. This is the part of the stored procedure I am sure is causing this to happen; IF @Access_Right_ID=8  or @Access_Right_ID=3  or @Access_Right_ID=9   BEGIN     DECLARE @Delimiter char(1)     ...

Re: Re: How to get fields from a SQL DB one by one
Hi , if you want "sql-fields" separate you will have to select them separate= ly, o.K.? First you will have to have e.g. DBI, >> #!/usr/local/bin/perl >> use DBI; then you will need a driver for your db (e.g. dbi::db2 ) or use DBI::O= DBC! use DBD::DB2::Constants; use DBD::DB2 qw($attrib_int $attrib_char $attrib_float $attrib_date $attrib_ts); Then you will need to connect to that database. >> # Open a connection and set LongReadLen to maximum size of column >> $dbh =3D DBI->connect("dbi:DB2:$dbname","$user...

How can I get the values from array and pass them one by one to the datagrid?
  Normal 0 false false false MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; ...

insert multiple values from one table into one column from another table?
Hi, I'm attempting to create an insert statement that gets the values from multiple columns and insert them into one column from another table, is there a simple solution to do this?Here is something similar to what i'm wanting done, just it's not the correct way to do it, i want value1, value2 and value3 from one table to be combined and put into the value1 column of another table, what am i doing wrong? INSERT INTO tablename2 (value1 + value2 + value3)SELECT value1FROM tablename1 thanks in advance! INSERT INTO tablename2 (SELECT val1 + val2 + val3 FROM tabl...

SQL Multiple values from one column query?
Hello, Im trying to make a query that returns data like so:I have the following columns; Name, Description, Link, Year, Sketched, Colouredin which Year is an Int, Sketched and Coloured are boolean and the rest are varchar(xx). Now I want a query in which I can choose to get something with the following values: Year either 2007 or 2008 , Sketched either true or false and Coloured is true.I tried something like this: SELECT Name, Description, Link, Year, Sketched, Coloured FROM ImageTabe WHERE (Year = @Year1 OR Year = @Year2 OR ...

Filter one datasource column with multiple values
I've done some poking around, but didn't see an answer on this. I have a GridDataSource that I want to filter when the page loads. But I want to filter a column by multiple values, like using a "contains" or an "in". The column is an integer value. I tried this: protected void GridDataSource_Selecting(object sender, LinqDataSourceSelectEventArgs e) { if (someCondition) { using (MyDBContext db = new MyDBContext ()) { e.Result = db.Employees.Where(emp => _currentUser.ShiftIds.Contains(emp.ShiftID)); } ...

Web resources about - How get one value from one column from sqldatasource? -

Top Ranked Articles
Top Ranked Articles - Free source code and tutorials for Software developers and Architects.; Updated: 23 Feb 2013

Using The LINQDataSource
-*+There is a new datasource control available in Visual Studio that works in much the same way as the SQLDataSource and the ObjectDataSource. ...

Gabriel Mongeon
Archive - Gabriel Mongeon

M ore d otnet .NET Interview Questions, ASP.NET, C#, VB.NET, XML, SQL Check Out √ .NET NOTES OOPS in .NET .NET ...

Architectural Overview of the Windows Presentation Foundation Beta 1 Release
Introduction Windows Presentation Foundation Beta 1 Windows Integration New Features WinFX SDK Exploring the New Features Introducing "Express" ...

About Mikesdotnetting
I started this site as somewhere to store answers to bits and pieces that I see asked frequently in the forums at . Rather than type ...

Using MiniProfiler with SqlDataSource ASP.NET WebForms Control
public class ProfiledSqlDataSource : SqlDataSource{ protected override DbProviderFactory GetDbProviderFactory() { // get the "base" DbProviderFactory ...

ASP.NET Pivot Table - RadPivotGrid for ASP.NET AJAX
... reports. RadPivotGrid allows easy customization of all data reports. Try now! Use any declarative data source control (AccessDataSource, SqlDataSource, ...

Sign on
Sign On • Join • Forums Home User Name * Password * Remember me next time ( I forgot my password ) SUBMIT YOUR WTF Content Random Article All ...

ComboBox Sample
ComboBox is an ASP.NET AJAX control that, like the AutoCompleteExtender , combines the flexibility of a TextBox with a list of options that users ...

Resources last updated: 12/25/2015 8:08:33 AM