Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
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 February 6th, 2007, 05:58 PM
Authorized User
Join Date: Jan 2007
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default New in .Net VB but learning datareader, access DB


I want to now a little about CodeBehind how to use it with SqlConnection, SqlCommand and SqlDataReader.

How i use:
<add name="ConnectionStringTest" connectionString="Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source=|DataDirectory|\DSNbase.mdb;Persist Security Info=True" providerName="System.Data.OleDb"/>

<asp:Repeater ID="test" runat="server" DataSourceID="SqlDataSourcetest">
<asp:SqlDataSource ID="SqlDataSourcetest" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionStringTest %>"
ProviderName="<%$ ConnectionStrings:ConnectionStringTest.ProviderNam e %>"
SelectCommand="SELECT [ID], [Name], [************], [Born], [Color], [Dog], [Images] FROM [Dogs] WHERE ([Dog] = 'YES') ORDER BY [ID]">

How can i take my asp:SqlDataSource and put it in my CodeBehind, so it use the ConnectionString from my Web.Config and so i can use my Repeater on my default.aspx site.. !?
Maybe if u got a great link that show "How to do" maybe om MSDN/MSDN2.

Old February 6th, 2007, 06:59 PM
Authorized User
Join Date: Jul 2005
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts

The SQLDataSource is not really used in code behind per say.. but you can use bind the SQL Datasource to your connection string by doing the followning.

1) Go to design view
2) from your Tools pallette drag an SQL Datasource on to your .aspx page.
3) Click on "Configure Data Source"
4) It will then prompt you to choose a connection fromn your Web. Config.
5) Bind your repeater to the SQLDatasource using code like the following:

 <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1"/>

Hope this helps.


Old February 6th, 2007, 08:49 PM
Authorized User
Join Date: Jan 2007
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts

yes but have do i make the datareader/sql conn on my CodeBehind

Similar Threads
Thread Thread Starter Forum Replies Last Post
VB.Net - Access DB - Date compare johneecc VB How-To 4 August 7th, 2008 04:23 PM
How to connect to Access db thru VB.NET? am_kuthus Visual Studio 2008 1 June 3rd, 2008 04:48 AM
Connecting to Access 20007 DB with vb.net JohnBoy VB.NET 1 May 21st, 2008 01:26 PM
VB.NET developer learning C# paulmarshall ASP.NET 2.0 Professional 1 February 27th, 2007 03:12 PM
Quickest way to write data to Access DB in VB.NET aslyon ADO.NET 4 September 22nd, 2004 08:00 AM

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