C# Tutorial 1:Getting Started and Mysql database Connection




C# Windows Form Application Mysql Connection c# – How can I connect to MySQL from windows forms? Using Visual C# Windows Forms with MySQL C# …

Original source


46 responses to “C# Tutorial 1:Getting Started and Mysql database Connection”

  1. Lisren I used your code exactly as you had typed it out but got the error msg. when I clicked the button that said "Keyword Not Supported:'datasource' " How do I fix this problem?

    using System;
    using MySql.Data.MySqlClient;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using System.Data.SqlClient;

    namespace MyWinFormApp1
    {
    public partial class Form1 : Form
    {
    public Form1()
    {
    InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
    try
    {
    string myConn = "datasource = localhost;port = 3306; username = root; password = steve";
    SqlConnection myConnection = new SqlConnection(myConn);
    SqlDataAdapter mda = new SqlDataAdapter();
    mda.SelectCommand = new SqlCommand(" select * from MyDatabase.atable;", myConnection);
    SqlCommandBuilder cb = new SqlCommandBuilder(mda);
    myConnection.Open();
    DataSet ds = new DataSet();
    MessageBox.Show("I am totally connected!");
    myConnection.Close();
    }
    catch (Exception ex)
    {
    MessageBox.Show(ex.Message);

    }

    }
    }
    }

  2. guys i'd like to replace localhost, port, username and password with textbox texts when pressing a button.
    I tried MyConnection.Replace("localhost", textBox1.Text); but it does not seem to work. Suggestions?

  3. i follow this tutorial
    now how can i create report
    another program i use report viewer. but i have problem with connecting the report viewer with mysql database
    any idea guy..

  4. Why did you write the line about creating a MySqlCommandBuilder cb = new… as you are not using it anywhere in the code? I thought this would have to go in the myConn.Open(cb) and MyConn.Close(cb)?

  5. Hi sir…!!! I have got a problem of signal encoding in c#. The user had to enter frequency and amplitude and accordingly we have to draw a sine wave of y=sin*2*pi*f*t , which should be displayed on a form. so please tell us how to draw the sine wave given frequency and amplitude?

  6. I am going to be taking a class soon and I was watching this video series before hand so it won't be such a shock to me when class starts.  My question is, What is the difference between c# and c#.net?  What should I be studying, and what are the advantages/disadvantages of learning this language compared to something like c++?  I thank anyone who can help me understand this so I can be pointed in the right direction with my learning.

Leave a Reply