Click here to Skip to main content
12,751,306 members (33,823 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# database
Can i get Database object from mdf file, like we use in SMO.

Database db=new DatbaseFromFile("abc.mdf"); // something like that (i m using c#)
Posted 20-Feb-13 3:54am
Sandeep Mewara 20-Feb-13 9:11am
What for? What exactly you are trying and want to do?
footballpardeep 20-Feb-13 9:22am
From this object i want transverse th ewhole database details, like all tables,rows in each table etc. (i see something like this by using SMO but that was for database on sqlserver management studio, but i want through .mdf file)

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Have a look at this page in it shows how to attach a database through the connection string. Look for the headings "Attach a database file on connect to a local SQL Server Express instance"[^]
footballpardeep 20-Feb-13 9:14am
Thanks for the link, i like that(this will help me later.)

But i want an Database object from mdf file. so that i can futher work on like this:
Tables tables=database.ALLTables();

Basically i want get the detail of database, like tables and after that transversing rows of table using this object.
Simon_Whale 20-Feb-13 9:20am
a good starter might be using the sp_tables stored procedure

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170215.1 | Last Updated 20 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100