Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

Database application

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Cdude - 12 Mar 2008 15:20 GMT
Hello I need to deploy an application.The application has to connect
to a database that is already attached to the DB on the machine.How
can i check what DB's are on the machine select the one i want to
connect to.
Peter Bromberg [C# MVP] - 12 Mar 2008 16:39 GMT
See here:
http://www.codeproject.com/KB/database/SubmitSQLInfoEnumerator.aspx
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short Urls & more: http://ittyurl.net

> Hello I need to deploy an application.The application has to connect
> to a database that is already attached to the DB on the machine.How
> can i check what DB's are on the machine select the one i want to
> connect to.
Roger Frost - 12 Mar 2008 16:46 GMT
> Hello I need to deploy an application.The application has to connect
> to a database that is already attached to the DB on the machine.How
> can i check what DB's are on the machine select the one i want to
> connect to.

If you want to prompt the user for the database to use, two days ago I found
a solution to this problem that uses COM Interops:

http://www.codeguru.com/vb/gen/vb_database/article.php/c5139

It's a VB example, but I was able to get it working in C# with:

ConnectionClass connection = new ConnectionClass();
object connectionObject = connection;
dataLink.PromptEdit(ref connectionObject);

I have no doubt that there is a way to avoid creating that connectionObject,
but all of my attempts failed (in a similar manor):

dataLink.PromptEdit(ref connection) ... "Argument '1': cannot convert from
'ref ADODB.ConnectionClass' to 'ref object'

I guess VB does some automatic casting that I have been unable to duplicate.

I figured out that the Data Link Properties dialog can be set to "default"
values by setting connection.ConnectionString before the call to
PromptEdit().

I use:

connection.ConnectionString = "Provider=SQLOLEDB.1;Integrated
Security=SSPI;Persist Security Info=False;Data Source=.\\SQLEXPRESS";

So the default server is the 1st SQL Express instance on the user's local
machine, unless they changed the name of that instance.  Now the user just
selects the database and we are good to go.  If they did change the server
instance name, or need to select a different server, the dialog makes that
easy as well.

If someone knows of a pure managed code solution that does the same thing,
please share. :)

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.