Solved

ODBCDataReader to SQLDataReader

Posted on 2010-09-16
2
474 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 28

Accepted Solution

by:
strickdd earned 500 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.NET 2008 - Windows Protected Your PC 7 52
VB.NET String Settings and Temp Folder Question 3 70
Using this function 4 40
reading an excel file vb.net 2 16
by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

756 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