Using VB.NET, how do I add the values from an XML file into an SQL Server database with a similar schema?
I don't know the methods off the top of my head but you ought to be able to load the file into a DataTable and then use ADO.net to get it into the database (look into the SqlBulkCopy class if you're using a SQL Server DB).
This ought to get you enough words to punch into and find a good example.
Easiest way is using the DataSet class's ReadXml() method. Then, as the user above mentions, the dataset contains one (1) DataTable. It's pretty easy to get that into SQL.
Use an XSL Transform to create an insert statement.
can't use xsl transform, you need a string for query, not another xml
Related
Anybody know if it's possible to;
Dynamically create LINQ classes for tables/columns that change regularly?
If that creation can be used in DynamicData.
A web app we are developing creates tables and columns in SQL. We want to edit these tables in DynamicData.
Thoughts?
Depending on what type of Database you are running, but you could always have a linq statement that queries the systems schema table and have it return the tables and columns. Then could use what you return and then use another linq query to break out the information from each table.
I used sqlmetal.exe from the SDK, it's a winner.
Are there any commands that make life easy with respect to this? I want to take the column schema of one datatable (.net datatable) and copy it to another new datatable.
I've seen something like:
SELECT * INTO [DestinationTable] FROM [SourceTable] WHERE (1=2);
Used in SqlServer.
I think this assumes that DestinationTable doesn't exist. It then creates the table and copies the schema from SourceTable the WHERE clause prevents any actual data from being copied.
I'm not really a database developer, so there's probably a much better way to do this.
I've found the answer. It is the .Clone method.
I want to import a typed DataSet with DataTables (not with TableAdapters) to my SQL Server database. The structure of all DataTables in the DataSet is the same like in the SQL Server database. With the same fields.
How can I import the whole typed DataSet to my SQL Server database?
Best regards
If you're just inserting data, and want the quickest way to insert data in to SQL Server, use the SqlBulkCopy class.
One of the WriteToServer overloads of that class accepts a DataTable as a source of data to be bulk loaded into the underlying table.
Can you use the SqlDataAdapter's Update method?
I will generate html table dynamically with some textbox and dropdownlist, user will enter their input in that. How to read these data in the controller?(MVC)
There is a relatively quick and easy way to get data from a well-formatted HTML table using the Microsoft .NET Framework Data Provider for OLE DB. Essentially, this allows you to specifiy a connection string which points at the page with your HTML table on it.
Here's an example connection string:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=http://www.your_web_address.com/yourHTMLTablePage.htm;Extended Properties="HTML Import;HDR=YES;IMEX=1"
You can the use the OleDbConnection and OleDbCommand objects to get to the data contained within the table. You can find these inside the namespace: System.Data.OleDb
I hope this helps?
/Richard.
Is there a general consensus on how to use SQL 2005's full text search with SubSonic? I know that I can use the InlineQuery and get an IDataReader, but is this the only way to do this? Also, how would I incorporate paging into it? Would I have to write the paging myself in the InlineQuery?
What I would really like to do is something like this:
new Select().From<Item>().Where("FreeText(Title, #title)").ExecuteAsCollection<ItemCollection>();
This way, I can use the built-in Subsonic paging functions and not have to write the entire query in SQL
This is one case with SubSonic where I think it is easier to create a stored procedure and build the collection from the result. Paging in a sproc isn't that difficult to implement (capture the sql generated by SubSonic and reuse it).
You can build a typed collection from the sproc by passing SPs.SPNameHere.GetReader() to the ItemCollection.Load() method. Make sure the sproc returns what a SELECT * FROM Item would return.
This won't work with SubSonic as it is now. I made a patch a while ago that would do something like this but it never got in. I'm wondering if it should be their or not what do you think?