DataSource Controls :: Concatenate Field For Unique Identifier?
Feb 3, 2010
I'm using Visual Web Developer Express 2008 and SQL Management Studio Express 2005. I need to link 2 tables to either present in a Master/Detail or GridView/Form view.The goal is to allow the user to view time card information from the AS400 (read only) and then enter any corrections into a SQL table. My problem is in trying to connect the two tables.I've asked the AS400 administrator to add a unique identifier field to the table (HAPOINT), but he says he can't. I've tried to concatenate a field within Visual Web Developer's Query Builder but keep getting errors.Table 1 - exists in AS400, is non-permanent (cleared every 3 months) and can't be modifiedEmpl ID WO Date In Time In Date Out Time Out Table 2 - exists in SQL Server, newly created for this project (no data yet, so can be modified)Rev ID Empl ID Date (of revision entry) X (Revise - y/n) Revised Time In Revised Time Out I tried finding a solution through the SQL Forum, but haven't gotten a solution, so I'm posting here. There are additional details at that post:http://forums.asp.net/p/1516929/3658517.aspx#3658517Can anyone tell me how to concatenate "Empl ID /WO / Date In / Time In" from Table 1 to produce a unique identifier that I can then use in Table 2, thus providing the link between the two tables? Or, is there another way?
I am just wondering how do I get the very last row of a join statement if I don't have any unique identifier... as in row_number field?Is there a way of creating a dummy column on my SQL statement to hold the record numbers of all records ..[1 to n] etc ???Id like to know how to do this and then I can get the MAX record number.Im using SQL server 2005 so the last() function doesn't work.
For example: INSERT INTO table (col1, col2, col3) VALUES ('value1','value2,'value3')But I would only like to insert the row if value3 isnt already present in col3 in some previous row. What is the best way to do that?And the insert command is run 50+ times in a loop (with different values each time for value3)
I realize that user names are unique, but is there another identifier associated with the username? If there is, how do I find out what it is for the user who is currently logged in?
I'm creating a website with sql server db (built in membership database). I design it best possible. Im reluctant to use text fields as identifiers, but this is pretty much my first sql server db.
1. The user registers himself, at the same time registering his company/organisation. I dont think many of them will have the need to register themselves to other companys (N:N) but you never know (anyway not a main concern at the moment).
2. This user becomes a superuser (level1), with the ability to register other users to the same company (level2 users). Finally level1 can register level3 users to the same company.
So you see the identifier will be everywhere in the sql commands. There are quite a few N:N relations as well, which I guess slows it down even more. The selections typically retrieves a few hundred to a few thousand posts, but like I said, many will be in N:N relations.
I'm going to write my own Authentication module and I need a unique identifier base on users requests header , I think [(user IP)+(user Agent)] can be reasonable but I know it's not completely safe do you know any other options or methods?
Code: <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SQL2008R2_799650_xnacsConnectionString %>" SelectCommand="SELECT [ArticleTitle], [articlehtml], [submittedby], [datesubmitted] FROM [Articles] where articleid ='@id'"> </asp:SqlDataSource>
and code behind is taking a url param (guid) and passing it to the select above it looks like this:
Code: protected void Page_Load(object sender, EventArgs e) { string id = Request["article"]; as simple as that, the problem is the page falls over saying it cannot convert string to Unique identifier, I'm new to asp.net but not c# so there are a few bits i'm trying to get my head round..
Right now I am creating this session with the session key "PhonePart" which is also the name of object I am passing in as a parameter in first method. In subsequent methods, I use the the same name to retreive and clear session value. My problem is, this approach works fine If I instantiate a single object of the class where these methods are defined and using that object call the methods, but when I create another instance of the same class and calls for instance method AddToSession and pass that instance, it overwrites the session value stored by the first instance of the class as the session key is the same that is "PhonePart".
Considering this scenario, is it possible that I somehow grab the name of the object as string in the calling method say "AddToSession" and create a session with that name? If Yes, then I can do the same in subsequent methods and retreive session value and also clear the session specific to that instance name without affecting the other session values stored by other instances.
i have a web application with form identification agains ActiveDirectory. The user is added to the aspnetdb and then we add his roles and profile.heres my question. If you have a user with "abcdef" for his sAMAccountName and then this user quit the job and someone else came in and we give him the SAME sAMAccountName, how aspnet will react? i guest it will see that the sAMAccountName already exist in the aspnetdb and will use it? if its true, then i will have a problem that the new user will inherit the old user access and profile!how can i solve this? i know theres a objectGUID attribute in AD that i can use but how can i use it with aspnetdb?
When the user clicks the edit button I want to pass the unique identifier from the item in the list to the parameter string so I can retrieve it in the edit page. how to retrieve the ID from the selected item?
I need to generate a Unique Reference number that has 7 digits.
It should be formatted in the following way:
1st: B (Ball), G (Gift), C (Cat)
2nd: represents year of booking A(2010), B(2011),C(2012), etc
3rd: represents the month of booking J(Jan),F(Feb),M(Mar),A(Apr),Y(May), U(Jun), L(Jul),G(Aug), S(Sep),O(Oct),N(Nov),D(Dec)
4th: days of booking A(1st) - Z(26th), 1(27th) - 5(31st)
5,6,7th: These are counters for the number issues each day. Each can be A-Z,0-9 giving a total of 46,656 combinations. So 0 is first, then 1, 2, 3, 4, 5, 6, 7, 8, 9, A-Z, then 00 to 0Z, then 10 to 1Z, then 20 to 2Z, etc
Now , the 1st Digit is a Character that I generate based on a condition and that shouldn't be a problem.
I have a Timer and a GridView who pulls info from the database every X seconds.Every time I query the database the field 'Comments' is replaced with whatever is on the database (since it's bound to it). I'd like to keep my previous value and keep adding into my Label the subsequent values queried from the database.
For instance, first time I query I get a value of "1" in the Gridview. Now someone changes the database row and next time I query it I have a value of "2". Well, I would like to concatenate the last value queried with the previous one and so on.
So at this point the GridView should show "1" and "2". Here is the piece of code I am talking about:
I need to concatenate address string. Is it better to concatenate using the formula field or concatenate in the Sql query itself? which one would be faster?
convert the code below to LINQ, converting my project to a wseb version usimg LINQ To SQL. The project contains 10 textboxes to possibly select from, but I'm only providing the first two textboxes to simplify my question.
mySQL_Statement = "SELECT IDENTIFICATION_DATA.NSC,ITEMISCD.RNC,ITEMISCD.NSC1 FROM IDENTIFICATION_DATA LEFT OUTER JOIN ITEMISCD on IDENTIFICATION_DATA.NIIN = ITEMISCD.NIIN" If Not ((TextBox1.Text = String.Empty) And (TextBox2.Text = String.Empty) Then mySQL_Statement = mySQL_Statement + " where " If Not (TextBox1.Text = String.Empty) Then mySQL_Statement = mySQL_Statement + "IDENTIFICATION_DATA.NSC IN (" + TextBox1.Text & ")" End If If (TextBox1.Text = String.Empty) Then mySQL_Statement = mySQL_Statement + "isnull(IDENTIFICATION_DATA.NIIN) = FALSE" End If If Not (TextBox2.Text = String.Empty) Then If astrixState = 0 Then If Not (TextBox1.Text = String.Empty) Then mySQL_Statement = mySQL_Statement + " AND IDENTIFICATION_DATA.NIIN IN (" + TextBox2.Text & ")" ElseIf (TextBox1.Text = String.Empty) Then mySQL_Statement = mySQL_Statement + " AND IDENTIFICATION_DATA.NIIN IN (" + TextBox2.Text & ")" MsgBox(mySQL_Statement) End If End If If astrixState = 1 Then If Not (TextBox1.Text = String.Empty) Then mySQL_Statement = mySQL_Statement + " OR IDENTIFICATION_DATA.NIIN IN (" + TextBox2.Text & ")" Else mySQL_Statement = mySQL_Statement + " AND IDENTIFICATION_DATA.NIIN IN (" + TextBox2.Text & ")" End If End If If astrixState = 2 Then If Not (TextBox1.Text = String.Empty) Then mySQL_Statement = mySQL_Statement + "AND IDENTIFICATION_DATA.NIIN NOT IN (" + TextBox2.Text & ")" Else mySQL_Statement = mySQL_Statement + " AND IDENTIFICATION_DATA.NIIN NOT IN (" + TextBox2.Text & ")" End If End If End If
there is a statement like " select t.f1, (select ta.f2 from ta where t.fk1=ta.fk1) from t inner join ta on t.fk1=ta.fk1 "? In SQL 2005, this will get the message "The multi-part identifier "t.fk1" could not be bound.".beacuse the result will contains duplicate data from table ta in one row.
Does anyone know how I can concatenate two columns in my subsonic datasource? I want to display a first and last name in this dropdownlist but I don't want to put them in the same SQL column.
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 followed [URL]. it was fine till server side but how would i be applying client side validation for unique field validation scenario on for example say username. i want to have username as unique.