|
-
January 7th, 2010, 04:27 AM
#16
Re: Migrate records from MySQL to Excel with c#
if you decide to use the mysql connector-net there's a chance I can guide otherwise you have to wait for someone else to help you
win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming
remeber to give feedback  you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation
private lessons are not an option so please don't ask for help in private, I won't replay
if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know
-
January 7th, 2010, 04:31 AM
#17
Re: Migrate records from MySQL to Excel with c#
I changed it to mysql-connector-net I don't have the previous error but a new one when I copy and paste the first code you gave, I get the following errors:
the name 'cmd' does not exist in the current context
-
January 7th, 2010, 04:35 AM
#18
Re: Migrate records from MySQL to Excel with c#
 Originally Posted by telmessos
the name 'cmd' does not exist in the current context
oops, sorry, I forgot to copy one more line last time, here's my test class again:
Code:
class MySqlTest
{
public static void RunTest()
{
MySqlConnection conn = new MySqlConnection("server=localhost;uid=csharp;pwd=csharp;database=csharptest;charset=utf8");
conn.Open();
MySqlCommand cmd = new MySqlCommand();
cmd.Connection = conn;
cmd.CommandText = "SELECT * FROM someTable";
MySqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
Debug.WriteLine(reader[0] + " -- " + reader[1]); // 0 and 1 because I've got two collumns in my test table
}
reader.Close();
conn.Close();
reader.Dispose();
conn.Dispose();
}
}
this is only a sample so there is no try/catch and your app will crash if an error occurs
Last edited by memeloo; January 7th, 2010 at 04:50 AM.
Reason: I forgot to dispose agian
win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming
remeber to give feedback  you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation
private lessons are not an option so please don't ask for help in private, I won't replay
if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know
-
January 7th, 2010, 04:45 AM
#19
Re: Migrate records from MySQL to Excel with c#
it seems to have no errors given. If I put the connection code on the form load section. Is it global? And how do I close connection at the end of the program? (asking too much )
-
January 7th, 2010, 04:48 AM
#20
Re: Migrate records from MySQL to Excel with c#
 Originally Posted by telmessos
it seems to have no errors given. If I put the connection code on the form load section. Is it global?
yes, if you make it a filed it will be class-wide accessible
 Originally Posted by telmessos
And how do I close connection at the end of the program? (asking too much  )
do this:
Code:
reader.Close();
conn.Close();
reader.Dispose();
conn.Dispose();
Last edited by memeloo; January 7th, 2010 at 04:50 AM.
win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming
remeber to give feedback  you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation
private lessons are not an option so please don't ask for help in private, I won't replay
if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know
-
January 7th, 2010, 04:52 AM
#21
Re: Migrate records from MySQL to Excel with c#
thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|