Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Data.SqlClient;
- using MySql.Data.MySqlClient;
- namespace WindowsFormsApplication11
- {
- public partial class save : Form
- {
- public save()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- string myConnection = "datasource=localhost;port=3306;username=root;Password=root";
- string query = "insert into store_data.item_details (item_id,item_name,item_qty,item_price) values('" + this.id_txt.Text + "','" + this.name_txt.Text + "','" + this.qty_txt.Text + "','" + this.price_txt.Text + "');";
- MySqlConnection connection = new MySqlConnection(myConnection);
- MySqlCommand cmdsave = new MySqlCommand(query, connection);
- MySqlDataReader dataReader;
- try
- {
- connection.Open();
- dataReader = cmdsave.ExecuteReader();
- MessageBox.Show("your Data has been saved ");
- while (dataReader.Read())
- {
- }
- connection.Close();
- }
- catch (Exception excep)
- {
- MessageBox.Show(excep.Message);
- }
- }
- }
- }
- save_Load(object sender, EventArgs e) {
- }
Add Comment
Please, Sign In to add comment