Click here to Skip to main content
15,901,426 members
Home / Discussions / Database
   

Database

 
GeneralRe: null to 0 Pin
Vipin.d23-Jun-07 23:42
Vipin.d23-Jun-07 23:42 
QuestionThrowing an Exception Pin
M. J. Jaya Chitra23-Jun-07 0:08
M. J. Jaya Chitra23-Jun-07 0:08 
AnswerRe: Throwing an Exception Pin
kubben23-Jun-07 2:02
kubben23-Jun-07 2:02 
GeneralRe: Throwing an Exception Pin
M. J. Jaya Chitra23-Jun-07 2:05
M. J. Jaya Chitra23-Jun-07 2:05 
QuestionAsgin new schema to a procedure and a table Pin
merwa22-Jun-07 22:59
merwa22-Jun-07 22:59 
QuestionUnicode Characcters in Query. Pin
Polite Programmer22-Jun-07 20:54
Polite Programmer22-Jun-07 20:54 
AnswerRe: Unicode Characcters in Query. Pin
Rob Graham24-Jun-07 3:13
Rob Graham24-Jun-07 3:13 
QuestionC#/ADO.NET Import Problems Pin
Bryan Bradford22-Jun-07 11:00
Bryan Bradford22-Jun-07 11:00 
Hey guys,

I am trying to write a C# program to import data from an Excel spreadsheet to a Sql table using a stored procedure.

So, I've created the connection objects:

OleDbConnection XLcon = new OleDbConnection(
@"Provider = Microsoft.Jet.OLEDB.4.0; Data Source = D:\Desktop\OA.xls;"
+ @"Extended Properties = Excel 8.0;");

SqlConnection SQLcon = new SqlConnection(
@"Data Source = (local); Integrated Security = SSPI; Initial Catalog = WebData");

And the Command Objects:

SqlCommand SQLcmd3 = new SqlCommand();
SQLcmd3.CommandText = "ImportOA";
SQLcmd3.CommandType = CommandType.StoredProcedure;
SQLcmd3.Connection = SQLcon;

OleDbCommand XLcmd = new OleDbCommand("SELECT [Date], [Order Application], "
+ "[Demand Orders], [Demand Units], [Demand Net], [Demand Gross], "
+ "[Demand Freight], [Demand Tax], [Demand Amount], [Demand Product Promo], "
+ "[Demand Ship Promo], [Fulfillment Units], [Fulfillment Net], "
+ "[Fulfillment Freight], [Fulfillment Tax], [Fulfillment Amount], "
+ "[Fulfillment Product Promo], [Fulfillment Ship Promo], [Return Orders], "
+ "[Return Units], [Return Net], [Month], [Quarter], [Year], [Week #], "
+ "[Return Amount] FROM [Excel$]", XLcon);

Set up the parameters:

SQLcmd3.Parameters.Add("@Date", SqlDbType.SmallDateTime);
SQLcmd3.Parameters.Add("@OrderApplications", SqlDbType.VarChar,10);
.
.
.
SQLcmd3.Parameters.Add("@ReturnAmount", SqlDbType.Money);

And then tried to import the data:

XLcon.Open();

OleDbDataReader XLread = XLcmd.ExecuteReader();
while (XLread.Read())
{
SQLcon.Open();

SQLcmd3.Parameters["@Date"].Value = XLread[0];
SQLcmd3.Parameters["@OrderApplications"].Value = XLread[1];
.
.
.

SQLcmd3.Parameters["@ReturnAmount"].Value = XLread[25];

SQLcon.Close();
}
XLcon.Close();
XLread.Close();

The code runs fine but it does not import anything into the table. The spreadsheet has data in it and I have verified that the Store procedure works so why can't I get the values in the spreadsheet into the table?


Thanks,
Bryan

AnswerRe: C#/ADO.NET Import Problems Pin
Rob Graham24-Jun-07 3:31
Rob Graham24-Jun-07 3:31 
QuestionThis query is making me crazy... [modified] Pin
_Zorro_22-Jun-07 9:45
professional_Zorro_22-Jun-07 9:45 
AnswerRe: This query is making me crazy... Pin
Krish - KP22-Jun-07 14:24
Krish - KP22-Jun-07 14:24 
GeneralRe: This query is making me crazy... Pin
_Zorro_23-Jun-07 16:21
professional_Zorro_23-Jun-07 16:21 
QuestionUsing OleDbReader.GetString to Retrieve Strings over 200 characters Pin
Nigel Cudjoe22-Jun-07 7:50
Nigel Cudjoe22-Jun-07 7:50 
QuestionSQL Server 2008 Pin
Brendan Vogt22-Jun-07 6:17
Brendan Vogt22-Jun-07 6:17 
AnswerRe: SQL Server 2008 Pin
Mike Dimmick23-Jun-07 1:37
Mike Dimmick23-Jun-07 1:37 
AnswerRe: SQL Server 2008 Pin
zhousz23-Jun-07 23:36
zhousz23-Jun-07 23:36 
GeneralRe: SQL Server 2008 Pin
Colin Angus Mackay24-Jun-07 2:24
Colin Angus Mackay24-Jun-07 2:24 
QuestionDatabase Architecture:Record Locking Pin
xbiplav22-Jun-07 4:59
xbiplav22-Jun-07 4:59 
AnswerRe: Database Architecture:Record Locking Pin
Pete O'Hanlon22-Jun-07 9:56
mvePete O'Hanlon22-Jun-07 9:56 
AnswerRe: Database Architecture:Record Locking Pin
Mike Dimmick23-Jun-07 2:03
Mike Dimmick23-Jun-07 2:03 
QuestionPlz solve this query Pin
Care Career22-Jun-07 3:31
Care Career22-Jun-07 3:31 
AnswerRe: Plz solve this query Pin
Blue_Boy22-Jun-07 3:41
Blue_Boy22-Jun-07 3:41 
GeneralRe: Plz solve this query Pin
AlexeiXX322-Jun-07 9:05
AlexeiXX322-Jun-07 9:05 
AnswerRe: Plz solve this query Pin
Krish - KP22-Jun-07 14:26
Krish - KP22-Jun-07 14:26 
GeneralRe: Plz solve this query Pin
Colin Angus Mackay24-Jun-07 2:27
Colin Angus Mackay24-Jun-07 2:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.