Click here to Skip to main content
16,014,748 members

Comments by 2gizzo (Top 15 by date)

2gizzo 18-Feb-11 2:44am View    
Thank you very much the above code worked with no problem, just one modification just realized that I was opening the wrong connection object, I was supposed to open sConnection instead objConnection (objConnection was for the excel file and sConnection was for the SqlConnection)
2gizzo 17-Feb-11 10:37am View    
the user is sa which has full access rights anyway right
2gizzo 17-Feb-11 9:32am View    
How would I go about doing the same task using LINQ? can you give some examples?
2gizzo 17-Feb-11 7:20am View    
Already did but I modified it to use a stored procedure instead of SQL INSERT but its not inserting, what surprises me the most is why am I not getting an error of any sort?
2gizzo 17-Feb-11 5:10am View    
sConnection and sCommand is initialized in the constructor here is how the constuctor looks
<pre>
// Constructor definition
public Uploader(string path, string connectStr)
{
this.path = path;
ConnectionString = connectStr;
constr = @"Provider=Microsoft.ACE.OLEDB.12.0;
Data Source=" + path + @";Extended Properties=""Excel 12.0;HDR=YES;""";
objConnection = new OleDbConnection(constr);
objCommand = new OleDbCommand();
objCommand.Connection = objConnection;
objCommand.CommandType = CommandType.Text;
objCommand.CommandText = "SELECT * FROM [Sheet1$]";
sConnection = new SqlConnection(connectStr);
sCommand = new SqlCommand();
sCommand.Connection = sConnection;
sCommand.CommandType = CommandType.StoredProcedure;
sCommand.CommandText = "spAddDebtor";
sCommand.CommandTimeout = 2000;

size = 0;
rowsaffected = 0;


// Initialize collections
names = new List<string>();
phones = new List<string>();
addresses = new List<string>();
contactPeople = new List<string>();

}
</pre>