Skip to content

Instantly share code, notes, and snippets.

@harshityadav95
Created July 17, 2017 21:46
Show Gist options
  • Save harshityadav95/5eeb7badbeaa3b71c9812156df8b3f34 to your computer and use it in GitHub Desktop.
Save harshityadav95/5eeb7badbeaa3b71c9812156df8b3f34 to your computer and use it in GitHub Desktop.
SQL in c#
using System;
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 MySql.Data.MySqlClient;
namespace labrat
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
string connetionString = null;
MySqlConnection cnn;
connetionString = "server=hackathon.cpdtrttdjtod.ap-south-1.rds.amazonaws.com;database=nap;uid=clu;pwd=lingayas;";
cnn = new MySqlConnection(connetionString);
try
{
cnn.Open();
string query = "insert into nap.datanet (download_speed,upload_speed,score,name,mac) values ('al','al','al','al','al')";
MySqlCommand cmdbase = new MySqlCommand(query, cnn);
MySqlDataReader myreader;
myreader = cmdbase.ExecuteReader();
MessageBox.Show("Connection Open ! ");
cnn.Close();
}
catch (Exception ex)
{
MessageBox.Show("Can not open connection ! ");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment