Casting Values SQL IN Function?

Nov 7, 2010

I have this problem where I am passing NVARCHAR parameter to a stored procedure, and the field type in the table for that parameter is INT.

I am doing that because I am using IN function, and for example if I want to send multiple parameters, that is the only possible way to do through .NET. Or not? The SP doesn't get executed because of the wrong type, and I am trying to cast the value, but I get an error. Here is how I am trying:
Example:

@Parameter nvarchar OrderStatusID = ('30, 40')

(o.OrderStatusID IN (CAST(@OrderStatusID as int)) OR @OrderStatusID IS NULL)

Is there a way to cast each value separately, or what will be the best way to cast whole value as INT.

View 2 Replies


Similar Messages:

Access Values Of Parameters Passed To A Function?

Jan 13, 2010

In my application if I get an exception I catch it and send stackTrace through email. I also need the values of parameters passed to this function. I can get the names of function and parameters using MethodBase class of System.Reflection.

View 7 Replies

What Is The Best Method Of Casting

May 20, 2010

Whats the best method of casting. I've been using syntax like this:

Button btnSubmit = (Button)item.FindControl("Btn_Submit")

but is this better or just different:

Button btnSubmit = item.FindControl("Btn_Submit") as Button

View 3 Replies

Creating A Function To Calculate Two Database Columns / Values?

May 11, 2010

I am using ASP.NET 2008 Visual Basic Language. I tried to create a function that multiply two values from two different tables and get the result presented in a label. The value is retrieved by referring to the primary key after the user selects from a DropDownList which is in another page using sessions.

I tried to build this code in the Load_Page event but it didn't display for me the total.

[Code]....

View 4 Replies

Web Forms :: How To Write A Function To Insert A Values In New Table

Jun 24, 2010

We have two database called First(Application) and Last(Workflow) I am submitting a Personal injury report which contains Date of Accident,time,eventID,eventDate,etc.

After submitted the button, these values in insert one of the database(First). At the same time few above column values in insert on another database(Last). Now i want to write a function to insert these values (selected values from both the tables) into new table in First Database.

Because we are adding new tables for audit purpose. User are saying their report are missing. that y we are inserting new table.

View 2 Replies

.net - DataGrid Values Not Updating After The Edit / Update Function?

Mar 24, 2011

I am using the following code to update the data in my datagrid.

But when I click update the value is updated in the database but it still shows old value in datagrid.

If I refresh the page after that then datagrid shows the updated value.

Code On Update Command:

protected void MySQLDataGrid2_UpdateCommand(object source, DataGridCommandEventArgs e)
{
string newData;
TextBox aTextBox;
aTextBox = (TextBox)(e.Item.Cells[0].Controls[0]);
newData = aTextBox.Text;
decimal comm = Convert.ToDecimal(newData);
string UpdateHiveCommission = "Update tbl_HiveCommission set Commission = '" + Convert.ToDecimal(newData) + "'";
MySqlConnection objMyCon3 = new MySqlConnection(strProvider);
objMyCon3.Open();
MySqlCommand cmd3 = new MySqlCommand(UpdateHiveCommission, objMyCon3);
cmd3.ExecuteNonQuery();
objMyCon3.Close();
MySQLDataGrid2.EditItemIndex = -1;
MySQLDataGrid2.DataBind();
}

View 3 Replies

Security :: Login Function Reading Previous Values?

Apr 3, 2010

I am facing a problem where when a user logins for the first time it shows the following error:
The resource cannot be found. Description:HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

[code]...

View 5 Replies

Web Forms :: Passing Session Values To A Function In JavaScript

Feb 11, 2012

If a value is stored in  a session object. How do I retrieve the session value in a function in javascript. I tried

var background1 = '<%=Session["test"]%>'

But I get blank

View 1 Replies

C# - Casting A Tiny Int From SQL Server?

Feb 17, 2011

I'm using linq to sql to populate a list of objects. One of the fields I'm interested in is stored as a tinyint. How should I declare this property type in my object definition? As a Short? Byte? Int16?

View 4 Replies

Asp.net - Casting An Object To A Long In C#?

Jun 16, 2010

I am pulling a 'long' value from Session, using a generic property, and it is crashing. so I have:

public static T Get<T>(string key)
{
if(...)
return (T)System.Web.HttpContext.Current.Session[key];
...
}


When debugging, the value is 4, and it crashes.

View 3 Replies

How To Pass A List Of Values To Compare In A SQL Function In SQL Server 2008?

Feb 18, 2010

I have an SQL Function with the following SQL within:

SELECT StockID FROM (SELECT DISTINCT StockID,
ROW_NUMBER() OVER(ORDER BY DateAdded DESC) AS RowNum
FROM Stock
WHERE CategoryCode LIKE @CategoryID) AS Info
WHERE RowNum BETWEEN @startRowIndex AND (@startRowIndex + @maximumRows) - 1

I have a Parameter @CategoryID - however I need to take in a category ID such as "BA" and translated this to a list of Category IDs such as "IE","EG" etc so my WHERE clause looks like:

WHERE (CategoryCode LIKE 'IE' OR CategoryCode LIKE 'EG') AS Info

I have a Lookup Table which contains the "BA" code and then all the real category codes this means such as "IE" and "EG".How do I have the CategoryID expand to multiple "OR" statements in my SQL Function?

At the moment the query as shown can cope with one CategoryID such as "IE", this is done as I want a category page such as category.aspx where a parameter "BA" is passed such as category.aspx?category=BA and this page will list all items with the category codes "EG" and "IE".

The reason I need this is there is a "parent" category code which has multiple "children" category codes which are different to the parent code. I am using ASP.NET and .NET 3.5 on the front-end if this helps.

View 2 Replies

C# - How To Handle ViewData Type Casting In MVC

Apr 21, 2010

i have a xml file and i am retrieving its value using Linq to xml and assigning it to ViewData.

[code]...

but foreach (var item in ViewData["Persons"] is giving type casting error..what should be the exact type csting so that i can retrive values in the format item.Fname.

View 3 Replies

Casting Request.Forms To String?

Mar 29, 2010

I'm calling a method like this:

DataTable dtModifiedData = detailsGrid.GenerateRowColumnDataTable(Request.Form)

The GenerateRowColumnDataTable method retrieves all form variables with <input> tags. My problem is that my columns are named in a strange format like this:

#X#_G1_NAME_1 so when I look at what's being rendered I see %23X%23_G1_NAME_1 so I thought I could use Server.URLEncode() around Request.Form but I'm getting an errot that it can't be converted to a string. What would you do in this case?

View 7 Replies

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

VS 2010 - Casting SiteMapNodeCollection To IEnumerable

Feb 19, 2013

Why it's not possible to cast a SiteMapNodeCollection (eg. SiteMap.CurrentNode.ChildNodes) to an IEnumerable<SiteMapNode>? I was wanting to do some filtering of the collection via LINQ, but this might not be possible?

The MSDN page says it implements IList, ICollection, and IEnumerable, so I don't see what the problem is.

View 4 Replies

How To Pass JavaScript Function As A Parameter In The Route Values Of Ajax Actionlink

Apr 20, 2010

I need to pass javascript function as a parameter value to the ajax actionlink in asp.net mvc app. how can we achieve this?

View 1 Replies

DataSource Controls :: Ienumerable For Dropdown - Loop Through The Values Coming From Function?

Feb 8, 2010

Here is my code, using LinQ to get the data from database.

public IEnumerable categoryData()
{
db = new DBModelDataContext();
var cat = from c in db.Categories
select new { c.categoryname,c.categoryid };
return cat;
}

trying to get the values (categoryname and categoryid) into textfiled and valuefield of dropdown list.

dt = new clsData();
ddlCategory.DataSource = dt.categoryData();

what is the code that i need to write to assign the categoryname to textfield and categoryid to valuefield. I mean how to loop through the values coming from the above function.

ddlCategory.DataBind();

View 2 Replies

Generic Casting To Access Text Property?

Sep 23, 2010

I have a situation where I'm iterating through all the controls on a form, specifically looking out for any of these three types of controls: Labels, TextBoxes, CheckBoxes

I can, of course, get the type of the control and then use a Switch-Case construct to cast labels as Labels, textboxes as TextBoxes, and checkboxes as CheckBoxes.

But I'm wondering if there's a way to do something with one or two lines of code to gain access to the Text property of each of these controls?

View 4 Replies

MVC :: IQueryable Casting To IOrderedQueryable Doesn't Work?

Nov 10, 2010

I am passed an IQueryable that might be already be ordered and that therefore might be an OrderedQueryable. I need to apply it a new ordering via reflection, anb before choosing if calling either OrderBy or ThenBy I need to now if the Queryable is IOrderedQueryable.

Now comes the problem! To see if may variable say query is an IOrderedQueryable I do:

IOrderedQueryable orderedQuery = query as IOrderedQueryable;

One might expect orderedQuery be null in case query is not an IOrderedQueryable ! INSTEAD orderedQuery is NEVER NULL. It takes the value of a different type!

I understand that this might happen because of deferred execution...

I tried also: query is IOrderedQueryable and it is always true!

How can I verify if query is actually an IOrderedQueryable before getting an exception when calling ThenBy?

The IQueryable comes from the Entity Framework 4.0

I am able to see it if I access the object that is behind the interface, but this way I would loose the benefif of using interface, and my class might not work with a different implementation of the IQueryable.

View 2 Replies

Casting A Request.Form Control From Code Behind?

Oct 15, 2010

Im dynamically generating an HTML Select Box, lets call it myselect. Im creating this select box based on some database values Im generating an HTML Select Box.. almost like a string that Im just spitting out to the page. So it's never a control in the codebehind, just part of a string thats rendered as HTML by the browser. If I submit my form, and in my codebehind I perform:

Dim myVal as String = Request.Form("myselect")

That code will give me the VALUE of the myselect select box. How can I refer to this control to cast it as a System.Web.UI.HtmlControls.HtmlSelect control? Request.Form seems to give me the value, but I want to reference the object itself..

View 3 Replies

Casting - Cast MembershipUser To Custom Class (ASP.NET)?

Oct 15, 2010

I'm using the default SqlMembershipProvider,but I've created a custom MembershipUser class (SoeMembershipUser) because I needed a "DisplayName" property.All the DisplayName does is look at the UserName and format it differently.When I try to cast a MembershipUser to a SoeMembershipUser user I get an InvalidCastException.

Exact error is:
"Unable to cast object of type 'System.Web.Security.MembershipUser' to type 'Soe.Tracker.SoeMembershipUser'."

Here is the code that fails:

SoeMembershipUser user = (SoeMembershipUser)Membership.GetUser(username); // invalid cast

I have also tried casting later like so:

MembershipUser user = Membershipship.GetUser(username); // ok
...
string displayName = ((SoeMembershipUser)user).DisplayName; // invalid cast

Here is the SoeMembershipUser class:

NOTE: I left off the constructors at first, but added them in later when I started having problems. Adding them made no difference.

public class SoeMembershipUser : MembershipUser
{
public SoeMembershipUser()
: base()

[code]...

View 2 Replies

Forms Data Controls :: Passing GridView Row Bound Values To JavaScript Function

Oct 28, 2010

I have a GridView with an image button in a TemplateField in the last column.

I would like to pass the GridView row values (Bound Field Values - a record) to a JavaScript function to create another html table of selected records in ClientSide (like jCart-A shopping cart).

I would like to know how to pass all GridView column values to the javascript when the image at the end of the respective row is clicked.

View 5 Replies

C# - Storing Session Id As A String And Casting It Back To GUID?

Jul 19, 2010

I´m trying to use session to store a value (id). The problem is that I have to store it as a string. When trying to use the instance of the id I get the error:

Exception Details: System.InvalidCastException: Specified cast is not valid.

Source Error:

Line 156:
Line 157: Nemanet_Navigation newFile = new Nemanet_Navigation();
Line 158: newFile.Nav_pID = (Guid)Session["id"];
Line 159:
Line 160:

This is where I get the id and that seems to work fine. Session["id"] gets the value.

[code].....

View 3 Replies

VS 2010 - Find Control And Casting Results In NullReferenceException

Apr 16, 2012

I'm using a third party control called an Accordion from Juice UI. Within that control, I have a table with labels.

VB.NET Code:
<juice:Accordion ID="accSwrlHddRepl" runat="server"> 
<juice:AccordionPanel runat="server" Title="HDD Information"> 
<PanelContent> <p> <table style="width: 99%;">
<tr> <td class="style2">
<asp:Label ID="Label2111111" runat="server" Text="Original HDD:"></asp:Label>   

[Code] ....

I can't access the label directly, so I'm trying to use the FindControl method to get it and set it's text property.

VB.NET Code:

CType(Me.accSwrlHddRepl.FindControl("lblFirstHddReplacement"), System.Web.UI.WebControls.Label).Text = "string"

But I get a NullReferenceException. So I moved the label outside of the table and put it just inside the accordion. The same behavior occurs. Then I gave the accordion panel an ID and did FindControl there, but the same issue occurs.

View 9 Replies

Data Controls :: Pass Multiple Eval Values To JavaScript Function Inside GridView

May 7, 2015

I want to pass hidden variable to javascript from href. Below is the code used

<input runat="server" id="hidOrganizationId" type="hidden" value="" />
<ul class="gloMenu">
<li id="liOrg" runat="server">
<a href="javascript: DataEncryption('../Admin/DetailPage.aspx?OrganizationId=' + hidOrganizationId)">
<b>Ordering Facility</b>
</a>
</li>

View 1 Replies







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