SQL Server :: Traversing DB Tables / Fetch The Value Inside Each [row][column], And Overall?
Sep 2, 2010
I read some articles before posting to try and solve my issue but i didn't get anywhere,
Here is what i'm trying to do:
1) I have an excel sheet with 1 EntrantID column and the rest are numbers (these numbers refer to answer codes for certain questions),
So for example, my excel sheet looks something like:
ID --- a1 --- a2 --- a3 --- a4 --- a5 --- etc...
1 ---- 32 --- 55 --- 12 --- 121 -- 50---etc...
The goal is to traverse thru every row, and every column and according to a checking condition for the values of answers, i will add the number to one of two columns in another table, so for example, i will start traversing a1, i will check it's value which is 32, if 32 > 0 and 32 < 60, then i will add 32 to columnA in another table, else, i will add it to column B in that table, then i will move on to the next value, a2 which is 55, it's < 60 so i will 'add' it to that same columnA in that table..
At the end, my other table, the one with results should look like this:
PersonID --- columnA --- columnB
1 ------------ 32, 55, 12 --- 121, 50
Hope i didn't confuse things, i'm trying to explain as best as i can lol.
So what i did, i imported the excel sheet to sql server, and i looked up SQL language to see if i can do that thru SQL itself, and i couldn't find a way to traverse columns, so next, i started an ASP.NET project, connected to the DB and i drag/dropped the table in my page as a GridView, where i'm trying to traverse it so i can get the values, check them against the range, and insert them in relative column.
I tried something like this:
DataTable dt = new DataTable();
dt = (DataTable)GridView1.DataSource;
DataTable temp = new DataTable("MyTable");
for (int i=0; i < dt.Rows.Count-1; i++)
for (int k = 0; k < dt.Columns.Count-1; k++)
if ((int)dt.Rows[i][k] > 0 && (int)dt.Rows[i][k] < 50)
temp.Rows[i][k] = dt.Rows[i][k];
That is not working, and i'm unable to do it. basically, i don't know how to fetch the value inside each [row][column], and overall i don't know how i can do the required task.
Inside a repeater there's a list of addresses ..when address link button is clicked, the address is shown inside of text boxes above repeater with all text boxes greyed out and an Edit button is rendered on the page OUTSIDE the repeater and below the text boxes..Now how do I edit this address ?
I need the AddressID of the address that has been clicked inside the repeater...
when Address link is clicked,DisplayAddress command event is fired inside of repeater's ITemCommand so what I did was assigned "AddressID" generated(when Adress link was clicked inside repeater) to a globally decalred string variable and tried to use that inside my Edit Button's click event so as to fill the Datasource(Method used to fill data source requires AddressID) and do stuff...didnt work
I have a table with about 300 OrgID's that I would like to pass into this sproc as the @Org_ID, so I don't have to do them one at a time. How would I do that?
insert into tblRelClients (client_ID, clientRel_ID)
select c1.client_ID, c2.client_ID from tblclients c1 inner join tblclients c2 on c2.OrgID = c1.OrgID where c1.OrgID = @Org_ID
i am using gridview where it fetches datas from sqldatasource, i want to made some calculations wit some fields from tables and then need to show in gridview. How to fetch single column values from sqldatasource. I only know this code which are used after displayed in gridview
i have a details table which include detailid, custname, address, classification , pincode, telephone, remarks and classification table contain classification id & classification.i want to insert detailid & corresponding classificationid to a new table detail_classification. How to write stored procedure for that?
I have to pass the session value to a business logic layer, I can pass it to the function from presentation layer but how can I access it directly in my business logic layer ? Also is it a good approach to pass it directly to business logic layer like
I want to find the sum of sales column from the table. Like today is 16-01-2014, i want the sum of sales column of 7 days back i.e. till 09-01-2014. I cannot put static dates as everyday date will change and every day i want that query to automatically see 7 days back records.
I have Gridview inside that i have RadioButtonList,Which is working perfectly. It also bind correctly.
Problem is when user navigate page,the value which was slected in previous page is not apper again.
Gridview is enabled with paging.
I want to save data on SUBMIT button which is outside gridview. So when user clicks this button it should get ALL selectedvalue of radiobuttonlist inside gridview INCLUDING paging and save it to database.
I have tried following code on Button_Click but its not working properly.
I am trying to write a linq query that will retrieve all the ID's from any asp tag. Also, the query needs to group everything together alphabetically. So for the example above, the linq query should return "lbl1", followed by "lbl2", followed by "txt1", and finally "txt2". Notice it did not grab the "bodyID" because it was not part of an ASP.NET tag. Is there an easy way to do this? I am using C#, by the way.
I am using bulk insert concept to export the data from dat file to tables(Two tables). I am using the temporary table for to do the calculation and insertion to two tables. My problem is whenever I selecting the temp table data after the execution of bulk insertion , the order is changing .I need to get the order as it is in file order(csv,dat,txt).
I am grabbing an XML feed an throwing it into a dataset. I am looping through the datatable that is in the dataset and adding a column to the datatable (Distance) that is the result of a calculation. What I then need to do is sort the dataset on the new column (Distance) I added, but it is not working... Here is a sample of my code.
In my Application, I am using User control which contains one GridView and few Buttons. GridView Contains CheckBox in Item Template of first Column for Selection purpose. Now on one of the Button's click Event I am traversing through the GridView and find which row is selected.
Following is my Code for traversing which is not working:
I want to rename aspnet_application table and its columns. 1- Does membership framework allow me to do that ?2- Will there be any problem in accessing System.Web.Security functions ?3- I have to change procedures and functions etc ?
I've read somewhere that ApplicationID is a unique id for a website (iis site path). But I'm still confused. When and why do I need this? I'm trying to implement asp.net membership for a website and I'll create some additional SQL tables (such as Companies, Services, etc) other than asp.net membership tables. So; do I need to include an ApplicationID column to these custom tables? Why?
anybody working on data exporting? I've 4 tables in my sql server database. I want to export these 4 tables data into one excel file in different sheets with column names.
Are there any ways in ASP.net to fetch data from the server without extending the session timeout? This needs to be done every few minutes without user interaction until the page is closed.
Additional context, as requested:
The pages in my webapp needs to poll the server every few minutes to check for a particular condition (emergency maintenance scheduled for 30 minutes time, in this instance). When the condition is true, the page will display a message to the user. When the condition is false, nothing needs to happen.
As I understand it, postbacks to the server reset the time until the session expires. We do not want the session to be extended/refreshed/reset/whatever the word is every time the page polls the server. I need a way to poll the server automatically without resetting the session timeout.