Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ODBCDataReader to SQLDataReader

Posted on 2010-09-16
2
Medium Priority
?
493 Views
Last Modified: 2012-05-10
I have an older .Net Windows Service that I am converting.  The Service polls ISAM files and gets the latest records.  The Service creates an ODBCDataReader for reading the ISAM files.

The conversion requires that I read the ISAM files and then write the resulting dataset to SQL Server.

Once I have the ODBCDataReader filled, then is there an easy way to write this data to a SQL Server 2005 database.  Currently the application is using a very long ConvertDataReadertoDataSet function that is timing out some service running on the Linux box.    I don't have any control over the Linux box so I have to make this work from my end.  

I have attached the function that is being used that is timing out the service.  The column count is 45 which is chewing up time ConvertDataReaderToDataSe1t.txt
0
Comment
Question by:sherbug1015
2 Comments
 
LVL 28

Accepted Solution

by:
strickdd earned 2000 total points
ID: 33700426
The basic idea would be to loop through the data reader and call a store proc. The code i posted is in C#, but it should be easy enough to convert.
SqlConnection conn = new SqlConnection(myConnString);
SqlCommand cmd = new SqlCommand("StoreProcName", conn);

conn.Open();

for( int i = 1; i<isamReader.Length; i++)
{
   cmd.Parameters.AddWithValue("@ParamName1", isamReader["Field1"].ToString()); //Probably should check for DBNull.Value before converting to string, you should also convert to the correct data type
   cmd.Parameters.AddWithValue("@ParamName2", isamReader["Field2"].ToString());
   .
   .
   .
   cmd.Parameters.AddWithValue("@ParamNameN", isamReader["FieldN"].ToString());

   cmd.ExecuteNonQuery();
   cmd.Parameters.Clear();
}

conn.Close

Open in new window

0
 

Author Comment

by:sherbug1015
ID: 33701182
That looks a lot cleaner than that other one.  Thank you.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question