473,385 Members | 1,400 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Copy data table to mysql table

I have a C# .NET Application which get data from QuickBooks via the ODBC Driver and save the result to C# data table.
So, I want to transfer this data table to a mysql table on my own server. That's the code I use:

Expand|Select|Wrap|Line Numbers
  1.  
  2. using System.IO;
  3. using MySql.Data.MySqlClient;
  4. //Add mysql dll on the .NET Tab in Project's references
  5.  
  6. string connStr = "DSN=QBTest;";
  7.  
  8.             string myServerAddress = "192.168.0.243";
  9.             string myDataBase = "CostTest";
  10.             string myUsername = "root";
  11.             string myPassword = "itpassw0rd_1";
  12.             string mysqlStr = "SERVER=" + myServerAddress + ";" +
  13.                                 "DATABASE=" + myDataBase + ";" +
  14.                                 "UID=" + myUsername + ";" +
  15.                                 "PASSWORD=" + myPassword + 
  16.                                 ";Allow Zero Datetime=true;";
  17.             MySqlConnection myConn = new MySqlConnection(mysqlStr);
  18.             //string connStr = "DSN=QuickBooks Data;OLE DB Services=-2;";
  19.             OdbcConnection conn = new OdbcConnection(connStr);
  20.             string comStr = "sp_report TxnDetailByAccount show TxnType, Date, RefNumber, Name, Memo, TextItemName, Debit, Credit, RunningBalance parameters DateFrom={d'2009-01-01'}, DateTo={d'2009-12-31'}, AccountFilterFullNameWithChildren='Cost of Goods Sold', SummarizeRowsBy='ItemDetail'";
  21.             OdbcDataAdapter da = new OdbcDataAdapter(comStr, conn);
  22.             try
  23.             {
  24.                 conn.Open();
  25.                 DataTable dt1 = new DataTable();//dataSet1.Account;
  26.                 da.Fill(dt1);
  27.                 dataGridView1.DataSource = dt1;
  28.                 dataGridView1.AutoGenerateColumns = true;
  29. }
  30. catch
  31.             {
  32.                 MessageBox.Show("Failed to connect with QuickBooks ODBC!");
  33.             }
  34.             finally
  35.             {
  36.                 conn.Close();
  37.             }
  38.  
  39.  
Mar 25 '13 #1
2 2787
r035198x
13,262 8TB
Use code tags when posting code.
So, what's the problem? Does the code compile? Does it run with errors?
Mar 25 '13 #2
the code run without errors. Until the line 28 it populates the result of my query, but all I need to transfer this result to mysql table
Mar 25 '13 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: rhepsi | last post by:
HII all, im working on postgresql database where i want to copy the data from one table to other table.... when im trying to write the sql query.. ERROR: 42601: syntax error at or near...
1
by: yasinirshad | last post by:
HI, Can anyone tel me How to copy data from a table in one database to a table in another database using sqlserver2005. Thanks in advance.
2
by: idorjee | last post by:
hello, i'm trying to write a perl cgi script to insert some values that i get from the my html form. i could manage to get the params from the html and process them (that part is not included in...
1
by: fritzb | last post by:
The mysql server is running. php is running. I can log into mysql locally, modify tables etc. php pages are running on an apache server. but I can not get a simple script in an web page to update...
12
by: cmghosh | last post by:
how to transfer excel worksheet data to mysql table?
2
by: servo | last post by:
I am using the following code. Why it does not insert record in the MySQL Table through php script: <?php $dbhost='localhost'; $dbuser='root'; $dbpass='newpass'; $mysqldb='mysql'; ...
3
by: printline | last post by:
Hello All I need a little help with a phph script to display some specific data from a mysql table. I have a mysql table with 4 columns and 10 rows. I want to display fx. data from row 4, 6, 8...
9
by: PI | last post by:
Hi Guys, I need some assistance with the following scenario please. I know this might be more of a MySQL post than a PHP one, but it is likely some developer has been here before and would be...
0
by: amskape | last post by:
Hi Pals, I am Anes , from Kerala ,India. I am a PHP Programmer Basically but have interest and now studying C++ , I plan to take data from MySql in C++, for that I install...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.