Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET 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 July 27th, 2007, 04:18 PM
Registered User
 
Join Date: Jun 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default dynamic database connection

For one of my projects, i need to develop a product in .net which will be connecting to a company's database to run specific queries. The database is unknown at development time.

1. Which component is able to let the user dynamically select a database connection and return a connection string such that i can save it? Or is there a better way to do this in .net code easily?

2. Given that connection string, and a usergiven query for that database, for how can i run that query? Is there a generic datareader, executescalar, etc

 any help much appreciated!!!!!

Lisa
 
Old July 28th, 2007, 04:39 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You can take a user entered connection string and assign it to a new connection object.

A user entered query can be executed to a datareader and then you could use the datareader as the datasource for a databound control (datagrid, gridview, etc). Without explicit column definitions and default settings those controls should simply display all the raw data as it is in the data reader.

-Peter
 
Old July 28th, 2007, 05:02 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You can also take a look at the *ConnectionStringBuilder classes that should help you build the connection string:

http://msdn2.microsoft.com/en-us/library/ms254947(VS.80).aspx

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic Connection Sting from ASP jayaraj ASP.NET 1.0 and 1.1 Professional 1 July 12th, 2004 07:49 AM
Dynamic connection string from ASP page jayaraj Classic ASP Databases 2 July 12th, 2004 07:44 AM
Dynamic connection string from ASP jayaraj General .NET 1 July 12th, 2004 04:19 AM
Setting Dynamic Connection String jayaraj General .NET 1 July 9th, 2004 08:19 AM





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