473,508 Members | 4,753 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Two SQL Statements in Page_Load (Advanced)

First and foremost, is it possible to execute two SQL statements that
grab different data out of the same database in the same Page_Load
subroutine?

I am building a music store and want to do a SQL for ASIN, Release
Date, Number of Disks, Price, etc... I have done this successfully.

The next SQL I am constructing is going to be for the track numbers,
names, and url for audio clips.

I guess my question is this: How would I go about successfully creating
two different SQL statements and referencing them in two different
datalists? I have successfully created and bound the first SQL to a
DataList and am running in to problems with the second one.

<!-- SQL statement for TrackListing [START] -->

Dim strSQLTracks as string = "SELECT ASIN, TrackNum, TrackName,
SampleURL FROM tblTracks WHERE ASIN ='" & strASIN & "';" & _
"FROM tblDescription WHERE ASIN = '" & strASIN & "';"

<!-- SQL statement for TrackListing [END] -->

Nov 19 '05 #1
2 1461
Sparky Arbuckle wrote:
First and foremost, is it possible to execute two SQL statements that
grab different data out of the same database in the same Page_Load
subroutine?

I am building a music store and want to do a SQL for ASIN, Release
Date, Number of Disks, Price, etc... I have done this successfully.

The next SQL I am constructing is going to be for the track numbers,
names, and url for audio clips.

I guess my question is this: How would I go about successfully creating
two different SQL statements and referencing them in two different
datalists? I have successfully created and bound the first SQL to a
DataList and am running in to problems with the second one.

<!-- SQL statement for TrackListing [START] -->

Dim strSQLTracks as string = "SELECT ASIN, TrackNum, TrackName,
SampleURL FROM tblTracks WHERE ASIN ='" & strASIN & "';" & _
"FROM tblDescription WHERE ASIN = '" & strASIN & "';"

<!-- SQL statement for TrackListing [END] -->


Yes it is possible.

You create a seccond datalist and bind that that to the result of a
second SqlCommand instance.

Next time please be more specific in the problem you are running into,
or the code that you are using.
On another note think about using parameterized queries, like stored
procedures to be allot less susceptible to SQL injection attacks. For
more information on that check out:
http://msdn.microsoft.com/msdnmag/is...n/default.aspx

---
Regards

Olle de Zwart
Nov 19 '05 #2
Dim strASIN
strASIN = Request.QueryString("ASIN")

Dim objConn as new
OLEDBConnection(ConfigurationSettings.AppSettings( "StrConnection"))

Dim strSQL as string = "SELECT ASIN, strTitle, strArtist, decPrice,
strLabel, intNumberDisks, dtReleaseDate, strReview, strImageDir " & _
"FROM tblDescription WHERE ASIN = '" & strASIN & "';"

Dim strSQLTracks as string = "SELECT ASIN, TrackNum, TrackName,
SampleURL FROM tblTracks WHERE ASIN ='" & strASIN & "';" & _
"FROM tblDescription WHERE ASIN = '" & strASIN & "';"

Dim objDataReader as OLEDBDataReader

objConn.Open()

Dim objCommand as new OLEDBCommand(strSQL,objConn)
dlMusic.DataSource =
objCommand.ExecuteReader(CommandBehavior.CloseConn ection)
dlMusic.DataBind()

dlMusic.RepeatColumns = 1

This is the binding for datalist - dlMusic

Nov 19 '05 #3

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

Similar topics

4
5116
by: Nhmiller | last post by:
This is directly from Access' Help: "About designing a query When you open a query in Design view, or open a form, report, or datasheet and show the Advanced Filter/Sort window (Advanced...
3
1831
by: DavidS | last post by:
Have parent.aspx from which I open Driver.aspx form via button on parent.aspx. When I first open the modal dialog, the driver.aspx Page_Load function is called. After I close the dialog, then...
0
1607
by: Itai | last post by:
Background: I have four Web Form pages with respective C# code behind files, all in the same project: localhost/vpath1 Page1.aspx Page2.aspx
14
13091
by: V. Jenks | last post by:
I'm a little rusty having not touched .NET for 6 months and I can't remember why Page_Load is happening twice in this code: private void Page_Load(object sender, System.EventArgs e) {...
5
3140
by: Andy | last post by:
Hi all, I have a site with the following architecture: Common.Web.dll - Contains a CommonPageBase class which inherits System.Web.UI.Page myadd.dll - Contains PageBase which inherits...
12
1837
by: TB | last post by:
Hi All: I am trying to create a variation on the standard datagrid, whereby the datagrid is only shown after pressing some buttons. This reason for this is that I would like to use the same...
1
1378
by: RAJ | last post by:
hi there, can anybody suggest me best sites for learning php with nested sql statements. i need sql query for searching from database with lots of options like using AND, OR etc even using...
9
4282
by: vivek | last post by:
Hi i have used some debug macro and called several times(hundreds) in the code. The purpose of the macro was to print the values at that time to the screen Now that i have finished...
3
6695
by: John | last post by:
Hi. I have a number of batch jobs that are ran nightly on our Windows 2000 based Oracle 8.1.7 (soon to be 9i) server. I have these designed just right, so the Windows Scheduled Tasks runs them...
0
7332
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,...
1
7058
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7502
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...
0
5635
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,...
1
5057
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...
0
3206
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...
0
1565
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 ...
1
769
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
426
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.