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; namespace Test { public partial class Form1 : Form { SqlCommand cmd; SqlConnection cn; public Form1() { InitializeComponent(); cn = new SqlConnection(@"Data Source=.\sqlexpress;Initial Catalog=Test;Integrated Security=True"); } private void button1_Click(object sender, EventArgs e) { try { cn.Open(); cmd = new SqlCommand("insert into Sample(Value) values('" + textBox1.Text + "')", cn); cmd.ExecuteNonQuery(); MessageBox.Show("Success"); cn.Close(); } catch { MessageBox.Show("Error"); } } } }
Module
Public strConnectionString as String
Load
.CONFIG
strConnectionString
SQLConnection
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)