Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#databse
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 2:54am
Comments
Sandeep Mewara at 20-Feb-13 9:11am
   
What for? What exactly you are trying and want to do?
footballpardeep at 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
good
Please Sign up or sign in to vote.

Solution 1

Have a look at this page in Connectionstring.com 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"
 
www.Connectionstrings.com[^]
  Permalink  
Comments
footballpardeep at 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 at 20-Feb-13 9:20am
   
a good starter might be using the sp_tables stored procedure http://msdn.microsoft.com/en-us/library/ms186250(v=sql.100).aspx

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

  Print Answers RSS
0 Dnyaneshwar@Pune 1,300
1 Sergey Alexandrovich Kryukov 660
2 ravikhoda 300
3 OriginalGriff 299
4 Manas Bhardwaj 240
0 Sergey Alexandrovich Kryukov 11,194
1 OriginalGriff 6,867
2 Peter Leow 4,795
3 Abhinav S 3,838
4 Maciej Los 3,575


Advertise | Privacy | Mobile
Web04 | 2.8.140421.2 | Last Updated 20 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid