Wrox Programmer Forums
|
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design 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 December 9th, 2004, 12:05 AM
Authorized User
 
Join Date: Aug 2003
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default datareader prob

hi all,

I want to fetch records from the database and display them against their labels in a table.
For e.g City: "New Delhi"
so for this i am using datareader as i dont have any other idea (in datagrid i dont think i can display my own labels/text against each record fetched.
Below is my code, am quite confused in using datareader. It is giving error : " Invalid token '(' in class, struct, or interface member declaration"


<%@ Import Namespace="System.Data.SqlClient" %>
<script language="C#" runat="server" > // this script is in my aspx file... no codebehind file used

SqlConnection myConnection = new SqlConnection("server=localhost;database=KTM;uid=s a;pwd=;persist security info=False");

SqlCommand myCommand=new SqlCommand("select * from city_center,city where city.city_id=city_center.city_id",myConnection);

myConnection.Open();//the error is on this line

SqlDataReader dr=myCommand.ExecuteReader();
Response.Write("<table width=550 align=center>")

        while (dr.Read())
        {
            Response.Write("<tr><td>City Name </td><td>"
            Response.Write (dr.Item["city_name"])
            Response.Write("</td></tr>)"
        
        }

        Response.Write ("</table>")


</script>


My aim is to display data in the below format in a table
where Ist column values are hardcoded and second one are fetched from the database.

Ist column II column

City ABC // fetched from database

Phone Phone no //fetched from database

and so on...

Whats the proper method ?


Help of any kind will be appreciated
thanks in advance

Vinay
 
Old December 22nd, 2004, 11:07 AM
Authorized User
 
Join Date: Dec 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hey vinay
i think the conection string is not proper
hope there wont be server or database attributes
"initial catalog" and "data source" are the attributes...
pls check ur connection string

 
Old December 23rd, 2004, 01:04 AM
Authorized User
 
Join Date: Sep 2004
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to nashnash
Default

Plz paste all code and table sample data so that i can fix...or check the connection string...check if its proper?

Thanks
Nash






Similar Threads
Thread Thread Starter Forum Replies Last Post
datareader in c# ryan.thomson C# 6 June 30th, 2009 12:48 AM
datareader MunishBhatia ASP.NET 2.0 Professional 2 October 17th, 2007 07:05 AM
DataReader truongnnhat ASP.NET 1.0 and 1.1 Basics 2 February 18th, 2005 12:41 AM
datareader surapongmax ADO.NET 1 October 8th, 2004 07:53 AM
Using DataReader() aadz5 ASP.NET 1.0 and 1.1 Basics 12 November 21st, 2003 06:32 PM





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