Click here to Skip to main content
16,004,854 members
Home / Discussions / C#
   

C#

 
AnswerRe: Deploying MySQL as backend for C# Pin
Adam Maras5-Dec-08 8:28
Adam Maras5-Dec-08 8:28 
AnswerRe: Deploying MySQL as backend for C# Pin
Wendelius5-Dec-08 8:29
mentorWendelius5-Dec-08 8:29 
QuestionHelp decoding base_64+GZipped string. Pin
Zeokat5-Dec-08 7:41
Zeokat5-Dec-08 7:41 
AnswerRe: Help decoding base_64+GZipped string. [modified] Pin
Guffa5-Dec-08 14:09
Guffa5-Dec-08 14:09 
GeneralRe: Help decoding base_64+GZipped string. Pin
Zeokat5-Dec-08 15:51
Zeokat5-Dec-08 15:51 
GeneralRe: Help decoding base_64+GZipped string. Pin
Zeokat6-Dec-08 4:37
Zeokat6-Dec-08 4:37 
QuestionGet the frequency of a audio-sound Pin
softwarejaeger5-Dec-08 7:33
softwarejaeger5-Dec-08 7:33 
QuestionSqlBulkCopy question Pin
Jon Stroh5-Dec-08 7:19
Jon Stroh5-Dec-08 7:19 
Is it possible to use SqlBulkCopy when a uniqueIdentifier column is the first column in the destination table? IF so how can I accomplish this.

Also Is there a way to use this line of code some how with a datareader when each datareader record is added to the destination table?

recnum = System.Guid.NewGuid();

FBasic8DataSet.LineItemRow newLineRow = this.fBasic8DataSet1.LineItem.NewLineItemRow();

newLineRow.RecNum = recnum;

Thanks Jon Smile | :)

Here is a code snippet I am using for SQLBulkCopy
string queryString = "SELECT `RecNum`, `Invoice Number`, `Date`, `Horse Name`, `Procedure Code`, `Procedure`, `Qty`, `AMOUNT`, `Cost` FROM `LineItem`";

OdbcCommand command = new OdbcCommand(queryString);

//Update Queries

lineItemTableAdapter1.DeleteWhereInvoiceNumberisNullQuery();

using (OdbcConnection connection = new OdbcConnection(connectionStringParadox))

{

command.Connection = connection;

connection.Open();

readerInv = command.ExecuteReader();

// Perform an initial count on the destination table.

OdbcCommand commandRowCount = new OdbcCommand("SELECT COUNT(*)FROM LineItem.DB");

OdbcConnection connectionRowCount = new OdbcConnection(connectionStringParadox);

commandRowCount.Connection = connectionRowCount;

connectionRowCount.Open();

long countStart = System.Convert.ToInt32(commandRowCount.ExecuteScalar());

MessageBox.Show("Total LineItem records" + Convert.ToString(countStart), Convert.ToString(countStart));

using (SqlConnection destinationConnection = new SqlConnection(destConnectionString))

{

destinationConnection.Open();

// Set up the bulk copy object.

using (SqlBulkCopy bulkCopy = new SqlBulkCopy(destinationConnection))

{

//Map columns

//SqlBulkCopyColumnMapping mapID =

new SqlBulkCopyColumnMapping("RecNum", "RecNum"); This maps the two colunms in question and causes errors becasue column types are incompatable. Source is autoInc(paradox Int) source is uniqueIdentifier.



bulkCopy.ColumnMappings.Add(mapID);

SqlBulkCopyColumnMapping mapInvNum =

new SqlBulkCopyColumnMapping("Invoice Number", "InvNum");

bulkCopy.ColumnMappings.Add(mapInvNum);

SqlBulkCopyColumnMapping mapPaid =

new SqlBulkCopyColumnMapping("Date", "DateWorkedOn");

bulkCopy.ColumnMappings.Add(mapPaid);

SqlBulkCopyColumnMapping mapInvTot =

new SqlBulkCopyColumnMapping("Horse Name", "HorseName");

bulkCopy.ColumnMappings.Add(mapInvTot);

SqlBulkCopyColumnMapping mapStat =

new SqlBulkCopyColumnMapping("Procedure Code", "ProcedureCode");

bulkCopy.ColumnMappings.Add(mapStat);

SqlBulkCopyColumnMapping mapDate =

new SqlBulkCopyColumnMapping("Procedure", "ShoeingProcedure");

bulkCopy.ColumnMappings.Add(mapDate);

SqlBulkCopyColumnMapping mapNotes =

new SqlBulkCopyColumnMapping("Qty", "Qty");

bulkCopy.ColumnMappings.Add(mapNotes);

SqlBulkCopyColumnMapping mapSatestx =

new SqlBulkCopyColumnMapping("AMOUNT", "Amount");

bulkCopy.ColumnMappings.Add(mapSatestx);


SqlBulkCopyColumnMapping mapcost =

new SqlBulkCopyColumnMapping("Cost", "Cost");

bulkCopy.ColumnMappings.Add(mapcost);


bulkCopy.DestinationTableName = "LineItem";

bulkCopy.NotifyAfter = 25;

bulkCopy.WriteToServer(readerInv);

bulkCopy.Close();

// Perform a final count on the destination

// table to see how many rows were added.

long countEnd = System.Convert.ToInt32(commandRowCount.ExecuteScalar());

MessageBox.Show("Total Line Item records copied" + countEnd);
AnswerRe: SqlBulkCopy question Pin
Wendelius5-Dec-08 8:37
mentorWendelius5-Dec-08 8:37 
Questionobject type [modified] Pin
nlowdon5-Dec-08 6:40
nlowdon5-Dec-08 6:40 
AnswerRe: object type Pin
Thomas Weller5-Dec-08 7:05
Thomas Weller5-Dec-08 7:05 
GeneralRe: object type Pin
nlowdon5-Dec-08 8:30
nlowdon5-Dec-08 8:30 
GeneralRe: object type Pin
Thomas Weller6-Dec-08 2:17
Thomas Weller6-Dec-08 2:17 
AnswerRe: object type Pin
Le centriste5-Dec-08 7:07
Le centriste5-Dec-08 7:07 
Questionstatus bar value in iexplorer Pin
kralece5-Dec-08 6:13
kralece5-Dec-08 6:13 
AnswerRe: status bar value in iexplorer Pin
Thomas Stockwell5-Dec-08 7:10
professionalThomas Stockwell5-Dec-08 7:10 
GeneralRe: status bar value in iexplorer Pin
kralece5-Dec-08 7:38
kralece5-Dec-08 7:38 
GeneralRe: status bar value in iexplorer Pin
Thomas Stockwell5-Dec-08 8:40
professionalThomas Stockwell5-Dec-08 8:40 
AnswerRe: status bar value in iexplorer Pin
Dave Kreskowiak5-Dec-08 7:53
mveDave Kreskowiak5-Dec-08 7:53 
GeneralRe: status bar value in iexplorer Pin
kralece5-Dec-08 15:03
kralece5-Dec-08 15:03 
GeneralRe: status bar value in iexplorer Pin
kralece7-Dec-08 7:51
kralece7-Dec-08 7:51 
GeneralRe: status bar value in iexplorer Pin
Dave Kreskowiak7-Dec-08 12:05
mveDave Kreskowiak7-Dec-08 12:05 
GeneralRe: status bar value in iexplorer Pin
kralece8-Dec-08 14:26
kralece8-Dec-08 14:26 
QuestionCreate a graf in Windows application Pin
Mc_Topaz5-Dec-08 6:00
Mc_Topaz5-Dec-08 6:00 
AnswerRe: Create a graf in Windows application Pin
Giorgi Dalakishvili5-Dec-08 6:39
mentorGiorgi Dalakishvili5-Dec-08 6:39 

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.