DataSource Controls :: Casting Bit Value From Table To Int?

Jul 28, 2010

I have a bit column that is saved as 1 or 0 in the database. I want to check the value in the table and then do an if statement depending if its 1 or 0. How can I convert it to an int?

i had

lockValue = (int)sqlCommand1.ExecuteScalar();


I want to assign it to the lockValue int variable. I then want to go on and check

if (lockValue == 1) {
// stuff
}

View 1 Replies


Similar Messages:

Forms Data Controls :: Casting Object In DetailsView Template Table?

Jul 22, 2010

I use the DetailsView control to display selected employee's data for HR. The list of data elements has gotten pretty long so I thought I'd put some tables & panels inside the ItemTemplate and EditTemplate. Testing with NO code behind in effect works perfectly on display & update. Now I need to manipulate some stuff in the code behind which requires me to cast the controls I'm after. However old cast code doesn't work (it says the row index doesn't exist).

First is a clip of the DetailsView which gives me 3 nice columns.

[Code]....

View 2 Replies

Forms Data Controls :: Casting Gridview Datasource To Datatable?

Mar 9, 2011

i try casting the gridview datasource to datatable using the following code but the datatable always nothing.

Dim DT As New DataTable
DT = DirectCast(gv.DataSource, DataTable)

the gridview is bound using dataset at code behind without using sqldatasource.

i m trying to filter the gridview without geting the data from database, is there is another way to do this?

View 4 Replies

DataSource Controls :: Select A Record From A Table And Insert Into B Table Using Linq?

Jun 29, 2010

how can i select a record from A table and insert into B table using linq?

View 2 Replies

DataSource Controls :: Way To Retrieve Data From A Table, Modify And Insert It Into Another Table

Jun 13, 2010

Basically i deal with two tables.i have a table T1 of the following format:id company_name i need to read this data and create a table T2 as followsi wrote the following code. it worked fine for retrieving data and modification but fails to insert the modified data into the 2nd table.the error is, it does not recognise the value for @token

ArrayList dynarr=new ArrayList(); // global variable
protected void Button2_Click(object sender, EventArgs e)
{
int row = 1; int i;
string strcmd = null;
string Connection = "Data Source=....";
SqlConnection conn = new SqlConnection(Connection);
string str = "select company_name from T1 where ID=@ID";
[code]...

View 2 Replies

DataSource Controls :: How To Insert StudentId From One Table Into Its Foreign Key In Another Table

Jun 9, 2010

I have two tables - Student and Advert.

I want to do the following;

1. Student is logged into their account (session is authenticated)

2. StudentID is primary key for that table, it is a foreign key for table Advert

3. When student is logged in, they create advert

What I want is their student Id to be input into the advert table when this new advert is created. How is this possible?

View 1 Replies

DataSource Controls :: How To Create The Pivot Table To Search The Table

Feb 26, 2010

I'm assuming I need to use a pivot table from what I've found so far. However, every one that I've seen has not had the date setup like I have.

I have a Gridview on my page which I need to be populated like so

Date NCMR

1/1/10-1/31/10 #

2/1/10-2/28/10 #

I want to do this for 10 months... bottom record being the current month (or last month). I would also like the Date to format to January 2010 I used the above date format because that is how it is in the table. Basically, I need to know how to create the pivot table to search the table for 1/*/10, 2/*/10, etc

View 3 Replies

DataSource Controls :: Update Another Table Automatically As Row Entered In First Table?

Mar 1, 2010

I'm sure this has been answered many times already, but I still can't seem to find exactly how to search for this issue, so apologies in advance.

Anyway, I have a VB script for entering a row of data into a table by a web user. When this row of data is entered, I wish to take some of the values from the columns of the "primary" table, and have that data automatically create a new row of data in a "secondary" table. I think I'm part of the way there, here is my script:

[code]...

"ProductsByMfr" is the "primary" table - the table that the user adds data into when the button click event is fired.

"DealerPricing" is a "secondary" table that I wish to have some of the data from the newly-entered row in ProductsByMfr copied into. Am I even close here?

View 8 Replies

DataSource Controls :: Update Table Based On Another Table?

Mar 1, 2010

I'm trying to update one my my tables from a field in another table.

I have Address fields on both tables and the old table has some addresses I need to copy over (I dont want to copy/paste or type them all in obviously). I basically need to:

[code]...

View 2 Replies

DataSource Controls :: How To Copy One Table To Another Table In Dataset Using C#

Jun 18, 2010

how to copy from one table to another table in dataset using c#

View 2 Replies

DataSource Controls :: How To Use Primary Key Table And Foreign Table

Jan 1, 2010

How i use primary key table & foreign key table data for retriving the data with each other.I had make both table i confuse how to use it.

View 1 Replies

DataSource Controls :: Can Transfer Data From A Table To Another Table

May 15, 2010

May you tell me how can I transfer data from a table to another table, the condition of non-repetition rows

as a procedure in database MS QSL server 2005 ,Works in the first day of the month I use the first table in the prodation environment it is contain the employee data and the second to update first table only

View 4 Replies

DataSource Controls :: Database Table: Move Row To The Top Of The Table?

Sep 5, 2010

I have a table in my aspnet database. I added a bottom row "Not Selected", if the user doesn't select from a databound drop down list. This row is at the bottom, because I just added it to the table data. Is there any way to move this one row to the top of the table manually? There is not "cut" and "paste" when I select the whole row.

View 3 Replies

How To Enable/disable Controls Against A User's Permission Via Type Casting

Jun 2, 2010

I want to enable/disable controls of a asp.net page against a logged in user's permission. say 'admin' & 'hr' can change user's birth date text-box in a page but others will see the text-box as disabled.

so i wrote a function like this

[code]....

View 3 Replies

Forms Data Controls :: Casting From Generic IList To Object During DataBind?

Feb 18, 2010

Okay, so I have a Generic IList of custom objects that I want to use as a datasource for a repeater.

[Code]....

In the WebForm inside the repeater, I place this code:

[Code]....

when I try to run it, I get the error "Unable to cast object of type 'System.Collections.Generic.List`1[MyCustomObject]' to type'MyCustomObject'. ". Which makes sense, really.

What's the best way round this? Is there any way I can get the direct cast working? I'm loath to have to create a custom list item that implements IBinding or something and bind that directly, as that'll mean a lot of legacy changes which may create further bugs. Or is there a better way?

View 3 Replies

Forms Data Controls :: ListView - ItemDataBound Event - Casting To DataRowView?

Oct 25, 2010

System.InvalidCastException was unhandled by user code

View 4 Replies

DataSource Controls :: Looping Through The Sql Table?

Jul 7, 2010

How to loop through the table get only paticular records based on the particular value and store it in a datatable.

for example, i've a table with two columns, Store name and Store number. For a single store name it can have mulitple store number like
[store name ] [store number]
a1 10
b1 12
a1 15
a1 21
b1 11
b1 22
a1 25
etc....
How to loop through the table and get all the records/ rows of a paticular store name and store it in a datatable.

View 7 Replies

DataSource Controls :: How To Add Existing Row Value And New Value In Table

Jul 8, 2010

I need to add Existing row value and new value in table
ex,
ProductID QTY
1 5
2 10
3 5

here the productid 1 is having QTY 5 now i update this Qty to 25

how do i form the query add QTY 5+20=25

View 3 Replies

DataSource Controls :: Add Columns To Table

Jan 21, 2010

I'm trying to add these 4 co,umns to the table as bit type woth a defaut of FALSE. What am I doing wrong here? I get a syntax error near (

create PROCEDURE [dbo].[AddADIFields]
AS
ALTER TABLE dbo.tblTESTS ADD (AI1 Bit 0,AI2 Bit 0,AI3 Bit 0,AI4 Bit 0)

View 2 Replies

DataSource Controls :: How To Update A Table In ASP.Net

Mar 12, 2010

I am sure this has been answered before but as newbie I am a little lost.
The environment is made of SQL Server 2005, VS2008 ASP.NET3.5 and VB language.
Here is the code that I have done:The fields are bit fields checkbox and radioButtonList (values -1 & 0) the is a variable that holds the primary key (Clid)

Dim conn As New SqlConnection()
conn.ConnectionString = ConfigurationManager.ConnectionStrings _
("S82e033-eWC").ConnectionString
Dim cmd As New SqlCommand
cmd = New SqlCommand("UPDATE tbl_CL SET CL_PDB= " & cbx_CLpdb.Checked & "CL_ICF=
[code]...

View 7 Replies

DataSource Controls :: How To Get Rid Of The Temp Table

Jul 3, 2010

I am doing this in my stored proc. Creating a temp table. Dumping the select results into the temp table and then select the info where the search string is based on the status name info.

because of the temp table, it is taking long to excecute. How can I get rid of the temp table and still seach based on the CurrentStatusName

Create proc [dbo].[usp_GetRequestsInfoOnSearchString]
(
@SearchString varchar(100)
)
as
Create TABLE #Request(
[RequestId] [int] NULL,
[RequestDate] [datetime] NULL,
[RequestText] [varchar](500) NULL,
[CurrentStatusId] [int] NULL,
[RiskLevelId] [int] NULL
)
INSERT into #Request
([RequestId] ,
[RequestDate] ,
[RequestText] ,
[CurrentStatusId] ,
[RiskLevelId] )
SELECT [RequestId]
,[RequestDate]
,[RequestText]
,CurrentStatusName = dbo.udf_GetRequestStatusName(CurrentStatusId)
,[RiskLevelId]
FROM [dbo].[Request]
select [RequestId] as [Request Id]
,[RequestDate] as [Request Date]
,[RequestText] as [Request Text]
,[CurrentStatusName] as [Current Status Name]
from #Request
WHERE ([CurrentStatusName] like @SearchString OR len(@SearchString)= 0 OR @SearchString is null)

View 1 Replies

DataSource Controls :: SQL Create New Table?

Jun 27, 2010

I have ASP.NET enviroment (C#) with SQL 2008 backend. I am using the ASP.NET membership provider. I need to create a table that contains member name, member role and third coumn (called "Registered for Conference"). I am using a button to initiate the action to call a stored procedure to write the selected value in the "Registered for Conference" column for the respective member.I know how to write the stored procedure, how to determine which user has processed their selection and how to write it to the "Registered for Conference" column of the table.I know that I can pull member name and member role with the following statement.

SELECT dbo.aspnet_Users.UserName, dbo.aspnet_Roles.RoleName
FROM dbo.aspnet_Roles INNER JOIN
dbo.aspnet_UsersInRoles ON dbo.aspnet_Roles.RoleId = dbo.aspnet_UsersInRoles.RoleId INNER JOIN
dbo.aspnet_Users ON dbo.aspnet_UsersInRoles.UserId = dbo.aspnet_Users.UserId

I need to understand how to create the table that will contain the member name, member role and third coumn (called "Registered for Conference"). This table cannot be a static table. In other words, this table needs to refect any updates to roles or members

View 2 Replies

DataSource Controls :: Get Data From More Than One Table?

Aug 5, 2010

how can I get data from more than one table using sqldatasource,,, am trying the following code but i get error "Invalid column name 'Category_tbl.CategoryI"

[Code]....

View 3 Replies

DataSource Controls :: Get Second Maximum From Table?

Apr 7, 2010

i have a table & i have to find out second mamimum or third maximum.Which is the best approach to do this?

View 5 Replies

DataSource Controls :: Duplicate Each Row In A Table?

Apr 20, 2010

I would like to duplicate each row in a table.

View 5 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved