I have two tables that effectively have a many to many relationship between them. Effectively I want to perform a query that returns results just from Table2. For simplisity table2 has 4 fields: theId, ForeignId, Info, extra
In table2 there can be multiple records with the same value of ForeignId (but each will have a unique theId which is the tables primary key).
I want to perform a:
select top (1) * where ForeignId=x order by extra
which will select 1 record for a given ForeignId
However, I then want to wrap that within an outer query where I have a list of foreignId (ie where ForeignId in ListOfX) but I want to return 1 result record for each value of foreignId. Does that make sense? So the result will be a set of records with one record for each value of foreignId and that record would have 'info' from the top(1) record from the inner query.
1 receive an xml string 2 data procress (retrieve data from db ãupdata from db ... ) 3 return an result of xml string
this the way I did
1 receive an xml string 2 parse xml by this way
string NO = xml.GetElementByTat("NO")[0].InnerText; string Name = xml.GetElementByTat("Name")[0].InnerText; use data to active with Database ex: select Manager from deparement where EMPNo = 'No' and EMPNAME = 'NAME'
3 return an result xml to the who call webservice string rtnXml = "<ProjectTeam>" +"<No>A121</NO>" +"<Name>Jack</Name>" +"<Manager>Allen</Manager>" +"</ProjectTeam>";
like this... but sometimes this way is mass.. do you have other idea to deal with xml ?
ite on dataset model and I used to write sql quires into dataset and call them with in my c# code as usual. and used the datatablein c#code to access the values of each column which corresponds to a sql column in the sql table. after a while I found my website going on too slowso I decided to use linq to sql classes. i can write queries in c# code
I have a checkboxlist in my asp.net page. I am adding items in it on design time. and i have a button which selects all the checkboxes inside checkboxlist. It works fine but there is another button which causes post back, and after postback, all checkboxes inside checkboxlist get unchecked and lose selection. How can I fix this ?
I want my Data Access Layer to be built very modular.Therefore I have data retrieval methods that sometimes are called directly from the business layer and sometimes are called by other data retrieval methods to create object dependencies.What is the best way to deal with database connections in the DAL?
a) Create a new connection in every method and dispose it afterwards.Good: Easy to write and to work with. Bad: Many connections are being opened and closed. (performance?)
b) Pass the connection as an (optional) argument.Good: I could reuse an open connection for multiple commands.Bad: I have to keep track of the ownership of the connection (who has to close it?) and cannot use the very neat "using" statements.c) Something else? (Connection as singleton maybe?)This is the first time I am writing a real DAL so I really could use some help from you experienced folks.EDIT: As it seems to matter, it's an ASP.Net Website Project.
However the companyid is a text string and the company may have an "&" in it which I know will truncate the string. I have seen that this can be overcome by using "UrlEncode" [URL] However I cant solve the syntax.
I'm trying to import a few hundreds of data to a SQL server database table from Excell Spreedsheet. In the taable, I created Id as key that is identity. How can I solve identity when I import excel data to the database table.
I recognized that based on a context in which I want to use some parameters, there are at least 4 kinds of encoding that are necessary to avoid corrupted code being executed :
Javascript encoding when constructing a javascript code, e.g. var a = "what's up ?" var b = "alert('" + a + "');" eval(b); // or anything else that executes b as code
I am trying to display selected file to a user right after he selects. Which means I have to save it to a temp location and change image src (or ImageUrl if we are talking about asp:Image).
And I am trying to use AsyncFileUpload (from Ajax Toolkit) for that. Apparently it has "OnUploadedComplete" server event, but sadly it isn't working.
I have a simple sql that selects records from some tables and insert them in one other table.This is what we need to do on a daily basis and we need to create a sql job for this.
I am developing a web application which will deal with online examination. The requirement is:
There can be n-number of sections in an exam and admin users should be able to create questions/answers and add to an exam. The questions should be displayed for a certain amount of time in the browser with meclock and it should move to next question automatically. User should not be allowed to open any other instance of the browser or login from another IP if the exam is in progress.
I am seeking community vote of how would someone design the application to meet all these criterias? What patterns should be used? What components to reduce the development time etc..My technology stack is C#, ASP.NET MVC or ASP.NET with SQL Server.
I have a toolkit tabbed container with an update panel in the bottom of each of the tabbed container's content template. There is also a radio button list an, a text box and a button. The user chooses the search criteria with the radio button list. They then enter the search text in the text box and hit the search button.
The update panel is then going to display the appropriate grid view and results, depending on what radio button was chosen. The logic to check the radio buttons is in the click event of the search button. I currently have one of the grid views and set it's visible property to true in the logic that checks to see which of the radio buttons was selected. My plan so far is to continue adding the other gridviews and doing this the same way with them. This will toggle the correct Grid View on.
I'm wondering if there is a better way of dealing with the Grid Views. There will be one of three to be displayed with in this update panel. They will have different result sets from different tables. Is my approach for turning them off and on with the visible property a bad idea? Should I be doing all of the ODS and grid view stuff programmatically? Is there a better way of doing this?
I need to know the best way to do the following. I have nested business level APIs (say level 1 & level 2). L1 needs to call L2. Both APIs use the database layer directly at their own nesting levels.
Now, in the database layer, I fetch the db connection from the pool each time as follows:
SqlConnection conn = new SqlConnection(connString); conn.Open();
Is it proper to fetch the db connection each time on every DB level call as above? I know it will return a connection from the ASP.NET connection pool. However, wouldn't it be better to maintain the same DB connection throughout the nested calls (or throughout the current http request lifetime)? Will fetching a connection from the pool each time cause issues with nested TransactionScopes?
Is there a better, cleaner way to do this in ASP.NET 2.0?
An ASP.NET 2.0 page displays a datalist of records. Each record can have many dates, so the dates are in a nested gridview (I chose a gridview over a datalist here because we want to be able to delete a date and this is easier done in a gridview). The parent record can never be deleted.
The display works fine: the nested gridview gets its datasource during the parent datalist's OnItemDataBound event.
The problem: the nested gridview's delete function. The date gets deleted without a problem (handled in the OnRowDeleting event), but somehow the redisplay is untying all the other nested gridviews from their datasources. The delete does not appear to cause a page postback, so I don't know how the other nested gridviews are losing their datasources.
I have a gridview with a select button. There are 181 records in the gridview all coming from the same database table. When I select the first 5 rows the details view comes up, but after that it doesn't show... The information that it is pulling is the same for the first 5 rows as the other 176 rows. Why won't it show the detailsview?!
I have a ajax tabcontainer which I load with tab panels at runtime. Now I am trying to do a fade in/out when a user selects a different tab panel. How do I approach something like this.
I have a problem.when i create a new web site and browse it with IE8 ,there is error(Internet Explorer cannot display the webpage) and now i am working with VS2008 and IE8.but i also have an older version of VS(VS2005) on the same computer.when i created a new web page with 2005 ,there is no problem and everything is ok. what is the problem with VS2008??i uninstalled it and reinstalled.but there is same error.i tried VS2008 on the another computer and i had no problem.
I'm working on a pretty basic little site that has content that is populated from a sql database. It's important to know that the data in sql includes some html (bolds, italics, ordered lists,etc). The problem I'm running into, involves the search results. On the search results page, I display the results from a sql query in a gridview. The sql query only returns the first 200 characters of the "Description" field, and then there is a link to click if the user wants to read the full description. The problem I'm running into is when the gridview tries to format the data that has an opening html tag, but no closing html tag (becasue the closing tag is over the 200 character limit.
I have some fields in my db that have a value of "NULL". These are displayed in the Data controls as "NULL". When I try to commit an update the Regex validator is catching this and not allowing the update because it doesn't match the pattern of the regex.
I've thought of one way of solving this, which is to add the value "NULL" to the pattern for the regex. I'm curious though if there is a better way to solve this issue.
I have 3 tables. Blog and Tag have a many to many relationship. BlogTag is a junction table with a quantity column.
**Blog** BlogID Title **Tag** TagID Name **BlogTag** BlogID TagID Quantity
I'm not sure how I handle the quantity column. I'd like it to store how many Blogs have a certain Tag NameHow do I deal with the quantity column when adding a new blog that has tags?