Friday, May 21, 2010

What is the method to make a database file in asp.net ?

please send me a example file with cording.

What is the method to make a database file in asp.net ?
To actually make a database?





Well to literally make a database from nothing you would have to import a reference to the COM type library ADOX:





http://msdn.microsoft.com/library/defaul...





See the ADOX Code Examples in Visual Basic | Create Method for code, which you will have to modify to the language changes that have taken place in vb.net (like dropping Set statements, etc.)





If this style of programming is too advanced for you, you can work with ADO.Net datasets to store XML data - the DataView object can give you SQL like sorts and filters.





The DataSet has a ReadXml method that can open an XML file as this kind of quasi database from the file system. And the DataSet has a WriteXml method that allows you to save the DataSet out to a file system.





I'm not going to actually sit and spend a half hour working up code for you and debugging it to see if it works. But the basic idea goes kind of like this:





DataSet ds = new DataSet("MyDoc");


DataTable dt = new DataTable(""myTable");


ds.Tables.Add(dt);


dt.Columns.Add("FirstName");


dt.Columns.Add("LastName");


//lets get at least one record in


DataRow dr = dt.NewRow();


dr["FirstName"] = "Fred";


dr["LastName"] = "Flinstone";


dt.Rows.Add(dr);


//now save our 'database'


ds.WriteXml(@"c:\temp\MyNewDatabase.xm...


//read it back in


ds.ReadXml(@"c:\temp\MyNewDatabase.xml...





The bottom code is all messed up by Yahoo. Sorry, nothing I can do about that...


No comments:

Post a Comment