Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 24th, 2007, 06:54 AM
Authorized User
 
Join Date: Dec 2006
Posts: 36
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via Yahoo to deb1980
Default Query in an another query

Hi,

I have a small query regarding running a query in another query.
Its in an aspx page. The code is as below:

<%
Dim MyConnection = New SqlConnection()

MyConnection.ConnectionString = ConfigurationManager.ConnectionStrings("AppConnect ionString1").ConnectionString

MyConnection.Open()

Dim cmd As New SqlCommand
Dim rs As SqlDataReader
Dim rs2 As SqlDataReader
Dim query = "select count(bank_id) from bank_master"
cmd.CommandType = CommandType.Text
cmd.Connection = MyConnection
cmd.CommandText = query
rs = cmd.ExecuteReader
If rs.Read() Then
 Dim rec = rs(0)
 If (rec > 0) Then
  Response.Write(rec & " banks registered in the system")
  rs.Close()
  Dim query2 = "select * from bank_master order by bank_id"
  rs2 = cmd.EndExecuteReader(query2)
  If rs2.Read() Then
   Response.Write(rs2(0))
  Else
   Response.Write("No banks yet registered in the system")
  End If
 Else
  Response.Write("No banks yet registered in the system")
 End If
End If
%>

Could you please help?

---
Best regards,

Debashis
__________________
---
Best regards,

Debashis
http://debashis80.spaces.live.com/
 
Old March 24th, 2007, 02:39 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Help with what? You didnt ask a question or provide a problem.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
 
Old March 25th, 2007, 08:33 AM
Authorized User
 
Join Date: Dec 2006
Posts: 36
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via Yahoo to deb1980
Default

ooops! sorry about that!
Am getting an error when i compile this. The error is:



Server Error in '/Accounts' Application.
--------------------------------------------------------------------------------

Input string was not in a correct format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.FormatException: Input string was not in a correct format.

Source Error:


Line 117:
Line 118: query2 = "select * from bank_master order by bank_id"
Line 119: rs2 = cmd.ExecuteReader(query2)
Line 120: If rs2.Read() Then
Line 121: Response.Write(rs2(0))





Similar Threads
Thread Thread Starter Forum Replies Last Post
Output Query to txt file from SQL Query everest SQL Server 2005 4 November 22nd, 2007 01:49 AM
how to make a query from an existing query raport SQL Language 3 November 13th, 2006 08:59 PM
I solved insert query.now see this Update Query. amit_mande@yahoo.com VB.NET 2002/2003 Basics 2 September 21st, 2006 12:48 AM
Syntax error in query. Incomplete query clause. dispickle ADO.NET 3 April 16th, 2004 01:04 PM
Error on Make-Table Query In Union Query rylemer Access 1 August 20th, 2003 07:42 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.