Advertisement
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.Threading.Tasks;
- using System.Windows.Forms;
- using System.Data.SqlClient;
- namespace ProductMaintenance
- {
- public partial class Form1 : Form
- {
- SqlConnection connection = new SqlConnection("server=localhost;user id=root123;database=test;allowuservariables=True;persistsecurityinfo=True");
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- private void button1_Click(object sender, EventArgs e)
- {
- connection.Open();
- SqlCommand cmd = connection.CreateCommand();
- cmd.CommandType = CommandType.Text;
- cmd.CommandText = "insert into [mytable] (Name,Surname,Address) values (' "+ textBox1.Text + " ', '" + textBox2.Text + " ', ' " + textBox3 + "')";
- cmd.ExecuteNonQuery();
- connection.Close();
- textBox1.Text = "";
- textBox2.Text = "";
- textBox3.Text = "";
- textBox4.Text = "";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement