Quantcast
Channel: Insert XML to SQL tables
Viewing all articles
Browse latest Browse all 9

Re: Insert XML to SQL tables

$
0
0

Thank you for the reply Kumar,

I went with the http://www.akamarketing.com/blog/135-importing-xml-into-sql-server-table-aspnet.html help.

After playing around with my code and such, Im stuck on this error. Maybe you could help me?

LINE 17 : SqlConnectionconnection =newSqlConnection("connectionString");
Error: {"Format of the initialization string does not conform to specification starting at index 0."}

 

My Code:

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace ConsoleApplication3
{
    class Program
    {
static void Main()
    {

DataSet1 reportData = new DataSet1();
    reportData.ReadXml("Items.xml");

SqlConnection connection = new SqlConnection("connectionString");
SqlBulkCopy sbc = new SqlBulkCopy(connection);
sbc.DestinationTableName = "ItemKey" ;
sbc.ColumnMappings.Add("ItemKey", "ItemKey");

connection.Open();

//table 4 is the main table in this dataset
sbc.WriteToServer(reportData.Tables[4]);
connection.Close();



 

 


Viewing all articles
Browse latest Browse all 9

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>