I need to loop through an XML document (no problem over there) and check if a value that i find is already in a (a) tag in a div in my XSL document that i am generating, only if the value is not in that (a) tag i should create a new (a) tag for it and put in in the div that i am checking... how to do it dynamically in XSLT?
I know this is a newbie question but, alas , that's what I am. How do I keep values in specifc sql server table unique, in other words how do I prevent any duplicates happening upon creating (inserting) a new table row?
I am returning a dataset from a method and trying to set one of the columns as Primary Key.
CategoryList.Tables[0].PrimaryKey = new DataColumn[] { CategoryList.Tables[0].Columns["CategoryNodeId"] };
Interestingly it gives me this error at run-time, These columns don't currently have unique values.
Now I perfectly know why this error should error, but there are no duplicate keys in this data column. I broke the code in between and bound the dataset to gridview to check if this column contains any duplicates and this is not the case. Here is the result set underneath. Have a look at the first column 'CategoryNodeId'.
CategoryNodeId CategoryId Name ParentCategoryNodeId [code]...
I'll try to make this concise. Anyways, I'm trying to only allow unique data to my database. my database. What I did before adding the entry is to use a Search Query for the value of the txtbox
"SELECT IDnum WHERE IDnum = '" & txtID & "'"
Then compare it with that of the txtbox.
IF objReader("IDNum") <> txtID.textbox then add the entry Else Display a Warning.
in the above code, I can detect the when the user entered an existing value. however, If the user entered a NEW (unique) value an error is Raised "Invalid attempt to read when no data is present" I hit the wall with this.So what I did, Since I can detect Duplicates and have errors when entering unique value, I used the
ON ERROR GOTO statement: I did it like this.
On Error Goto errHandler
If objReader("IDNum") = txtID.textbox then lbl1.text = "Existing Record" objReader.close() [code]....
The Code does what I need but its kinda long, I bet there is an elegant way to do this.
I've got a database table with a very large amount of rows. This table represents messages that are logged by a system. Each message has a message type and this is stored it it's own field in the table. I'm writing a website for querying this message log. If I want to search by message type then ideally I would want to have a drop down box listing the message types that have come up in the database. Message types may change over time so I can't hard code the types into the drop down. I'll have to do some sort of lookup. Iterating over the entire table contents to find unique message values is obviously very stupid however being stupid in the database field I'm here asking for a better way. Perhaps a separate lookup table which the database occasionally updates listing just the unique message types that I can populate my drop down from would be a better idea.
The platform I'm using is ASP.NET MVC and SQL Server 2005
How does System.Guid.NewGuid() know that the values it generates are unique, for example when i use in a loop?Does it internally store data somewhere? .
I am reading a column value from the database. The field is defined as 30 charswide. If the vale read is less than 30 chars, I need to pad it on the right side withblanks. So that the value when written to a text file will appear to be left justified.How can this be done? I know how to right justify like below. But how do I left justifyand pad on the right side with blanks?Right(LTRIM(RTRIM(CustomerNum) + SPACE(30)),30) As CustNum -- This right justifies.This will NOT left justify so I am stuck :LEFT(SPACE(30) + LTRIM(RTRIM(CustomerNum)),30) As CustNum -- This WIL NOT justify as I wish
I need a way to create unique values for a property in my custom server control..
In this case I will have the poroperty called "Name" and I neeed the value of Name to be unique for each "instance" of the control...
So for instance if I have a page with more then one instance of the control, I dont want the value of the Name property for these instances to be allowed to be the same..
...to put it kind of simple, if I dont remember this incorrect, I want it to be sort of like the ID property..but with another name then ID.
This is my UserRoleList.aspx.cs Code where i am passing the session variable to the page Default.aspx.cs..
And the error is: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints. I have gone through many pages , and tried by making the AllowDbNull property making True and then different things.
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data;
[code]...
This is the code of the second page Default.aspx.cs where i have to user the session varaible to pass in the SQL fucntion named GetDataByUserId as shown below:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls;
How would i make a select statement select the row with the nearest values? e.g.: I have 3 labels, labels1 2 and 3, with values of 1.2, 2 and 5.8 In my table i have 4 columns, first is the data im after, and the next 3 relate to the three labels. I want to select one row, where the values of labels match it the closest.......
From this below stored Procudure, using VB.Net code can i get the Values like "Number of Rows Affected" and "Yes / No" Value from "Select"Stored Procudure:ALTER PROCEDURE [dbo].[lookup] @week_date datetimeAS
DECLARE @currweek datetime, @inweek datetime IF @week_date = '10/14/2010' BEGIN UPDATE dbo.work_status SET ob_flag = 0, ob_update_date = NULL WHERE dbo.work_tatus.week_date ='10/14/2010' SELECT 'YES' END ELSE SELECT 'NO' RETURN 0
Is there a better way to write the code below? I have quite a few blocks that are similar, and this is making the code in the Viewpage very messy to work with. The data value with the associated label only needs to be output when certain conditions are met, which is almost always if the value is not null. The options I can think is to use a response.write to atleast minimize the usage of the ASP script tags, or to format the webpage is such a way that the label displays with an appropriate n/a type value.
I am getting always output parameter values null albeit in stored procedure I assigned output param values to 2.both of (MYTOTAL,MYPER) should return 2 but always null.
some code to attempt retrieving multiple output values
How generate the unique no. 1,2,3 and so on .... on button click of each new user ..
the code mentioned below is a readwrite coding in vb.net ...
but the problem is it generate the same id for different users on button click event... but i want the no. of times button clicked the new ids will be generated
I am trying to create a simple page with a drop down list which has 3 items. Choosing any of those 3 items calls for a specific constructor in the script. Using VB 2008
public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { if (DropDownList1.Text == "Coupe") { //Response.Write("You chose the Coupe"); string Engine; string Transmission; string Wheels; string Safety_Features; string Key_Systems; string Interior; string Mileage; Altima A1 = new Altima(Engine, Transmission, Wheels, Safety_Features, Key_Systems, Interior, Mileage); Response.Write(A1.displayAuto()); } if (DropDownList1.Text == "Hybrid") { Response.Write("You chose the Hybrid"); } if (DropDownList1.Text == "Sedan") { Response.Write("You chose the Sedan"); } } public class Altima { //private member variables private string Engine; private string Transmission; private string Wheels; private string Key_System; private string Safety_Features; private string Interior; private string Mileage; //public accessor methods public void displayAuto() { System.Console.WriteLine(Engine, Transmission, Wheels, Safety_Features,Key_System, Interior, Mileage); } //constructors public Altima(string Engine, string Transmission, string Wheels, string Safety_Features, string Key_System, string Interior, string Mileage) { this.Engine = Engine; this.Transmission = Transmission; this.Wheels = Wheels; this.Key_System = Key_System; this.Safety_Features = Safety_Features; this.Interior = Interior; this.Mileage = Mileage; string Engine = ("2.5-litre DOHC engine with 175 HP and 180 lb-ft of torque or 3.5-litre DOHC engine with 270 HP and 258 lb-ft of torque"); string Transmission = ("-speed manual transmission or available Xtronic CVT® with manual mode"); string Wheels = ("17 inch 5-spoke aluminum-alloy wheels (2.5 S) or 18 inch 5-split spoke aluminum-alloy wheels (3.5 SR)"); string Safety_Features = ("Six standard air bags as part of Nissan Advanced Airbag System (AABS)"); string Key_System = ("Nissan Intelligent Key® with Push Button Ignition"); string Interior = ("Leather"); string Mileage = ("Up to 5.6 L/100 km on city with eCVT"); }//coupe -------> First constructor public Altima(string Engine, string Transmission, string Safety_Features, string Mileage) { this.Engine = Engine; this.Transmission = Transmission; this.Safety_Features = Safety_Features; this.Mileage = Mileage; string Engine = ("2.5-litre DOHC engine with 175 HP and 180 lb-ft of torque or 3.5-litre DOHC engine with 270 HP and 258 lb-ft of torque"); string Transmission = ("-speed manual transmission or available Xtronic CVT® with manual mode"); string Safety_Features = ("Six standard air bags as part of Nissan Advanced Airbag System (AABS)"); string Mileage = ("Up to 5.6 L/100 km on city with eCVT"); }//sedan -----------> Second Constructor public Altima(string Engine, string Transmission, string Mileage) { this.Engine = Engine; this.Transmission = Transmission; this.Mileage = Mileage; string Engine = ("2.5-litre DOHC engine with 175 HP and 180 lb-ft of torque or 3.5-litre DOHC engine with 270 HP and 258 lb-ft of torque"); string Transmission = ("-speed manual transmission or available Xtronic CVT® with manual mode"); string Mileage = ("Up to 5.6 L/100 km on city with eCVT"); }//hybrid -----------> Third constructor } }
how do I ouput the values from the constructors when I choose the specific list box item?