hey guys just need some help here..i don't know how program it in C#..

i need a class file in C# using Microsoft Visual Studio 2008 that will save inputted data to the MySQL database..and also a class file that will transfer data from a table to another table in the database..pls badly need it..looking forward to your immediate response..tnx so much

P.S. can you send the files(database files and class files) SNIP

Edited 7 Years Ago by happygeek: email snipped

Don't you love those people who obviously just joined the forum for the single purpose of asking a complicated question in a manner that makes it seem just a simple as "which way is the bathroom?"

Reminds me of when I first started programming. Once you get into the mindset. You look a problems completely different. And the questions you ask are much more refined. But sometimes its the difference between "Do you know were I could get some lumber and a hammer?" and "I would like one(1) free house please."
lol.


as for the OP. Glad024 try you some of this http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=576

Don't you love those people who obviously just joined the forum for the single purpose of asking a complicated question in a manner that makes it seem just a simple as "which way is the bathroom?"

I do .. I do :) moreover - you can see that I give my help mostly for newbies ..

Reminds me of when I first started programming. Once you get into the mindset. You look a problems completely different. And the questions you ask are much more refined. But sometimes its the difference between "Do you know were I could get some lumber and a hammer?" and "I would like one(1) free house please."

Yeah, you're right .. everything's possible. But this words made me feel a lil bit confused:

can you send the files(database files and class files) SNIP

But the only person, who can cast light on this situation is OP. Let's wait till he/she will answer .. if he/she will :)

0) Is this something specific or do you need just an example?

1) When you say "save", is it OK to overwrite the content in the database or just add to it?

2) If this is for a specific table, what are the columns of the table?

3) When you say "transfer", are the columns in both tables the same and will you empty the first table when the data is transferred?

4) Do you have the mySQL ODBC driver installed? Do you know the connection string?

5) If an example is delivered, are you OK with modifying it to match your exact table needs?

6) How is the data input? From a file or other data source?

7) What is the format of the input data?

8) What have you tried so far? Do you have any code for this?

Edited 7 Years Ago by thines01: omission

Hi glado24! Got here as fast as I could...

Now, did you need the complete application with documention and help files attached or just the MySQL database-wrapper interface library?--just kidding--:D

If you search the forum, you should find many examples of what you are asking for, and even some threads related specifically to MySQL. Put together some code using these and other examples from the web and then post more specific question/need based on any problem your having.

There is great DB coding help in this forum when you post a more specific question. ;)

Cheers!

Comments
lol :D
`Inline Code Example Here`
public void MySqlSelect(string dbUser, string dbPass, string dbServer, string dbName, string dbQuery, ref DataSet data){
            //Main Funtion
            try
            {
                string mysqlDriver;         
                string mysqlServer;         
                string mysqlCharSet;    
                string mysqlDatabase;   
                string mysqlUser;       
                string mysqlPassword;   
                string mysqlOption;     
                 mysqlDriver    = "Driver={MySQL ODBC 5.1 Driver};";
                 mysqlServer    = "Server=" + dbServer + ";";
                 mysqlCharSet   = "charset=UTF8;";
                 mysqlDatabase  = "Database=" + dbName + ";";
                 mysqlUser      = "User=" + dbUser + ";" ;
                 mysqlPassword  = "Password=" + dbPass + ";";
                 mysqlOption    = "Option=3;";

                string myDbConnectionString = mysqlDriver + mysqlServer + mysqlCharSet + mysqlDatabase + mysqlUser + mysqlPassword + mysqlOption;

                //##########################################
                // Example Connections
                //##########################################
                //attempt to connect to the database remotly
                //OdbcConnection myDbConnection = new OdbcConnection("Driver={MySQL ODBC 5.1 Driver};Server=192.168.1.139;charset=UTF8;Database=art_center;User=root; Password=#pas;Option=3;");
                //OdbcConnection myDbConnection = new OdbcConnection("Driver={MySQL ODBC 5.1 Driver};Server=192.168.1.102;charset=UTF8;Database=art_center;User=root; Password=#pas;Option=3;");
                //OdbcConnection myDbConnection = new OdbcConnection("Driver={MySQL ODBC 5.1 Driver};Server=localhost;charset=UTF8;Database=art_center;User=root; Password=#pas;Option=3;");

                //local machine connection Windows    
                //OdbcConnection myDbConnection = new OdbcConnection("Driver={MySQL ODBC 5.1 Driver};Server=127.0.0.1;charset=UTF8;Database=art_center;User=root; Password=;Option=3;");
                //OdbcConnection myDbConnection = new OdbcConnection("Driver={MySQL ODBC 5.1 Driver};Server=192.168.1.139;charset=UTF8;Database=art_center;User=root; Password=;Option=3;");

                //OdbcConnection myDbConnection = new OdbcConnection("Driver={MySQL ODBC 5.1 Driver};Server=" + tempString + ";charset=UTF8;Database=art_center;User=root; Password=" + tempPass + ";Option=3;");
                //##########################################


                OdbcConnection myDbConnection = new OdbcConnection(myDbConnectionString);


                myDbConnection.Open();
                OdbcCommand myDbCommand = myDbConnection.CreateCommand();

                Console.WriteLine("Querying database {0} with query {1}\n", myDbConnection.Database, myDbCommand.CommandText);

                        Console.Write("Login info is not null.\n");
                        //Create a dataset to store data
                        DataSet myDataSet = new DataSet();


                        //Create a temporary variable to store login name and password
                        //string[] temp = new string[3];

                        //find the correct database field for user name 
                        myDbCommand.CommandText = dbQuery;   //"SELECT * FROM " . DbTable . ";";

                        OdbcDataReader myDbReader = myDbCommand.ExecuteReader();

                        int fCount = myDbReader.FieldCount;

                        if (myDbReader.HasRows)
                        {
                            Console.Write("Query Results:\n");
                            for (int i = 0; i < fCount; i++)
                            {
                                String fieldName = myDbReader.GetName(i);
                                string columnData = myDbReader.GetString(i);

                                //temp[i] = columnData;

                                //#######################################################################
                                //Display fields and columnData in console to show that the query works.
                                //for testing.
                                //#######################################################################
                                Console.Write(i + " " + fieldName + " " + columnData + " " + ":\n");

                            }

                        }

                        Console.WriteLine();
                        Console.Write(": Assigning dataset :");
                        data = myDataSet;
                        Console.Write(": Assigning complete :");
                        Console.WriteLine();



                        //Load data into a datatable
                        //OdbcDataAdapter myDataAdapter = new OdbcDataAdapter(mySqlStatement, myDbConnection);
                        //DataSet myDataSet = new DataSet("ac_employee");
                        //myDataAdapter.Fill(myDataSet); //, "ac_employee");

                        /* DataTable tb = myDataSet.Tables[0]; // ("ac_employee");
                                         foreach (DataRow row in tb.Rows)
                                         {
                                             string somename = (string)row["ac_employee"];
                                             //lstNames.Items.Add(somename);
                                             mtbMemberId.Text = somename;
                                             Console.Write(somename + "\n");
                                             //myDbRead.GetName(0);
                                         }*/

                        //mtbMemberId.Text = myDataSet.tables(0).rows("empNum").toString();

                        //DataRow myDataRow = myDataSet.Tables["ac_employees"].Rows[0];
                        //mtbMemberId.Text = myDataRow.ItemArray.GetValue(1).ToString();

                myDbReader.Dispose();
                myDbCommand.Dispose();
                myDbConnection.Close();
            }catch (Exception ex){

                Bitmap image1 = new Bitmap(Properties.Resources._1356151198_Database_1);


                DialogResult result = BetterDialog.ShowDialog("Database Error",
                                                              "Database Error",
                                                              ex.Message + " : You tried [something] and it didn't work. Check the ODBC database connection.",
                                                              "", "Ok", image1);
                Console.Write(": Check your ODBC connection :");

                if (result == DialogResult.OK)
                {
                    Console.WriteLine("User accepted the database error dialog\n");
                }
                //MessageBox.Show("There was an error connecting to the database. Please ensure you are using the correct ODBC driver 5.1. That your mySQL database is running. And you have the remote SSH tunnel established.");
                Console.Read();

            } finally {


            }
        }

You will need to understand SQL to modify this code. Please do not use it exactly. I only post this so you can begin to understand what a function to handle mysql through ODBC looks like. Also take note that the dataset is passed through the function using pass by reference. If any of this is beyond your level of skill study:

1) Pass by reference
2) Using DataSets with Data Grid Views
3) Data Adapters
4) ODBC drivers / connectors for MySQL.
5) Non Execute Querys

Hope this helps a little.

Take care.

Edited 3 Years Ago by dioioib: edit for reasons - non-execute querys

I was.
I find that this sight in particular is full of unfinished posts which are closed. What gives? The quality of posts on this site are a stark contrast to those on stackoverflow. I find there are more functional answers there than here and would love to correct any of those issues I can. Is this site actually here to help people find real world answers to problems?

Edited 3 Years Ago by dioioib

Unfortunatly the majority of the unfinished threads tend to stem from people who want their assignments doing for them without having to learn or do anything themselves, even if it's just Googling it. So they usually abandon the post when they realise they're not getting spoon fed.

It's a shame because it seems to have gotten worse over the last 6 months and puts people off posting here or geniune threads get buried in the mess, I know I post less because of it.

Sometimes poeple figure it out for themselves and don't post their solutions (i might have done that in the past).

Agree with Chris. I'm not a registered user of stack-overflow, but are the people there very friendly towards people who obviously show no effort?

Daniweb caters well for the new and beginner coders, with plenty of us willing to help with seemingly incredibly simple questions, provided the OP can show they've tried first.

Where I (and probably a lot of others) draw the line is when people ask for code to solve their problem without posting any further detail or their own work. If SO is willing to do other people's work and coursework for them, they are free to post there, but the posters will lose out in the long run.

If I went to SO and copy-pasted some cryptography code because I don't know how to do it. Have I learnt how to do cryptography? No. Does it fix my current issue? Probably. Will I be able to fix it later or extend it? Probably not.

Going to a forum and doing a piece of coursework on behalf of someone because they don't understand or are too lazy to do helps no-one. When given exams at job interviews they will fail and if someone employs them on faith, all that will happen is "I have X to do but I don't know how, please post code" and now you're doing their job for them as well.

This might be an over-cynical viewpoint, but it's one I believe in.

It's great that you want to help, but sometimes giving the answer away isn't actually helping.

It's not so much a case of which form is better it's just a case of unfortunatly there a lot of posters, who are quite often student's who go to university for the money (they counted for 1/3 of my course at uni), who post on a number of forums to do as little work as possible because after all the more doors you knock on the more answers you get.

I think its the design and colour scheme of DaniWeb, one of it's most difinitive aspects (a friend once said "what is that purple forum called"), that attracks more beginners because the colour is welcoming and not as intimidating as hard white schemes that are often used on programming forums. Unfortunatly people often get tared with the same brush (young drivers for example).

So as much as it's necro posting dioioib is providing the answer to a question someone else might have in the future which we can't really complain about too much (as long as it's a valid answer).

Edited 3 Years Ago by ChrisHunter

This article has been dead for over six months. Start a new discussion instead.