473,770 Members | 6,950 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting database fields (rows) to appear as columns in datagrid

I'm looking at a quick way to get results that are displayed as rows to
display as columns.

I have three tables:-
- The Questions for the survey
- The Results of the survey (Columns are listed as question numbers)
- The Survey Extra Results (As additional questions can be listed into
the Questions table, has 3 columns (a link/id to the survey id, a
link/id to the question id, and the answer the user gave).

I need to list the results of the survey and the extra results for the
survey on one row in a datagrid for each survey.

Any ideas?

Aug 6 '06 #1
1 1466
I currently have the following which basically makes a SQL query for
every single row required and makes a union, however this query can
easily get too complex and when 50+ surveys have been created, it will
start to lagg.

Dim j As Integer
dsSurveys = GetAllSurveys(" Attendee")
For j = 0 To dsSurveys.Table s(0).Rows.Count - 1

SelectQuery = ""
dsQuestions = GetAllQuestionN umbers("Attende es")
If dsQuestions.Tab les.Count <0 Then
If dsQuestions.Tab les(0).Rows.Cou nt <0 Then
Dim i As Integer
For i = 0 To
dsQuestions.Tab les(0).Rows.Cou nt - 1
If
GetColumns(dsQu estions.Tables( 0).Rows(i).Item (0).ToString) <"" Then
SelectQuery +=
GetColumns(dsQu estions.Tables( 0).Rows(i).Item (0).ToString) & " AS [" &
dsQuestions.Tab les(0).Rows(i). Item(0).ToStrin g & EndOfString(i,
CInt(dsQuestion s.Tables(0).Row s.Count) - 1)
Else
SelectQuery += " (SELECT
SurveyExtra.Sur veyExtra_Answer FROM SurveyExtra WHERE SurveyExtra_Gui d
= '{" &
dsSurveys.Table s(0).Rows(j).It em("Survey_Addi tionalQS").ToSt ring & "}'
AND SurveyExtra_Que stionGuid = '{" &
dsQuestions.Tab les(0).Rows(i). Item("Question_ GuID").ToString & "}') AS
[" & dsQuestions.Tab les(0).Rows(i). Item(0).ToStrin g & "] "
If Not i =
(CInt(dsQuestio ns.Tables(0).Ro ws.Count) - 1) Then
SelectQuery += ", "
End If
End If
Next
End If
End If

Query += "SELECT Survey.Survey_I d AS [Survey_Id],
Survey.Survey_G uID AS [Survey_GuID], " & SelectQuery & " FROM Survey
WHERE Survey.Survey_I d = " & dsSurveys.Table s(0).Rows(j).It em(0) & "
AND Survey_Type = 'Attendee'"

If j = (dsSurveys.Tabl es(0).Rows.Coun t - 1) Then
Query += ";"
Else
Query += " UNION "
End If

Next

Aug 7 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2842
by: Alex | last post by:
Hi all, I'm writing a small web application which searches a database based on a date field, and populates a datagrid control with the results. The datagrid control has selection buttons added to it to view additional details about the selected result (a second database query is triggered). I want this second query to pop up in a new window, the way it would if I used "window.open" in javascript. I've added a function in the
4
1544
by: sivashankar | last post by:
hello experts.... -i'm having a datagrid with 10 columns and 4 rows and one submit button. -the fields are eno,ename,eid,and 4 check boxes -after entering values when i clik the submit button the values i entered must passt to next page and displayed in datagrid and at the same time it must be inserted in the database -plz help me...how to do it.
0
1388
by: John Shum | last post by:
I prepare a UserControl that act as a lookup control, once the code is enter in the TextBox, the description will appear in another TextBox outside the UserControl of the same row in a DataGrid via javascript. I attempt to get the client ID of the TextBox (with provided ID of that TextBox as "ext_desc") by the following code inside the Page_Load() event of the UserControl (named Color_Control): for(int i = 0; i < DataGrid1.Items.Count;...
3
9925
by: | last post by:
I wrote a class in VB.NET to export the contents of a datagrid to Excel. It works perfectly on my machine, but it fails on my customers' PCs that have identical versions of Win XP (SP1) and Excel (SP1) installed. The error is: System.Runtime.InteropServices.COMException(0x800A03EC): Exception from HRESULT: 0x800A03EC. at Microsoft.Office.Interop.Excel._Worksheet.Paste(Object Destination, Object Link) at...
3
4279
by: Frustrated Developer via DotNetMonster.com | last post by:
I have posted a couple times on here already and found the user community to be very helpful. I took on a project before I realized how difficult a time I'm having working with a database. Assistance would be greatly appreciated! I am trying to allow certain users to be able to preview a database's contents without being able to update which I've accomplished. I've created a "Preview" button and set the datagrid to READ ONLY. Now I want...
9
3838
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web site for a small club I belong to and one of the features I would like to include is the ability to allow users to upload image files. unfortunately the servers web root www folder only allows READ and EXECUTE permissions, which makes it...
4
3079
by: dallasfreeman | last post by:
I'm looking at a quick way to get results that are displayed as rows to display as columns. I have three tables:- - The Questions for the survey - The Results of the survey (Columns are listed as question numbers) - The Survey Extra Results (As additional questions can be listed into the Questions table, has 3 columns (a link/id to the survey id, a link/id to the question id, and the answer the user gave).
3
1378
by: =?Utf-8?B?SmliZXkgSmFjb2I=?= | last post by:
Hi: I have an interesting problem that I don't know how to solve. I need to display rows of one of these grid controls on two columns of the grid. So, row1 would appear on row1, column1, and row2 would appear on row1, column2 and row3 would appear on row2, column1 and row4 would appear on row2, column2 and so on. These grids do not allow adding rows dynamically, and that's a shame,
1
7312
by: tucson | last post by:
I have a gridview that has a blank row with 2 input fields: file to upload, and a description of the file. They click Add and a new row is added, Remove and the row is removed. The problem is: When a new row is added, I loop through the existing gridview rows, store the data in a dataset, and rebind. In debug mode, I see the values I entered but when I rebind, it's not displayed in the gridview. Here's the code aspx code: ...
0
9425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10225
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10053
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9867
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8880
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7415
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5312
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3969
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3573
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.