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.
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.
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.
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.
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.
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?
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.
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.
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?
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
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.
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.
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?
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.
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..
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()
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.
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.
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.