using System;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Data;
namespace Proje
{
public partial class Register : Form
{
SqlConnection con = new SqlConnection("Data Source=MURATCANY\\SQLEXPRESS;Initial Catalog=proje;Integrated Security=True");
public Register()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
if (con.State == ConnectionState.Closed)
{
con.Open();
}
string kayit = "INSERT INTO Kullanici (kullanıcı_adi, sifre, telno,yas ) VALUES (@kullanıcı_adi, @sifre, @telno, @yas )";
SqlCommand com = new SqlCommand(kayit, con);
com.Parameters.AddWithValue("@kullanıcı_adi", textBox1.Text);
com.Parameters.AddWithValue("@sifre", textBox2.Text);
com.Parameters.AddWithValue("@telno", textBox3.Text);
com.Parameters.AddWithValue("@yas", Convert.ToInt32(textBox4.Text));
// com.Parameters.AddWithValue("@yas", Convert.ToInt32(dateTimePicker1.Text));
com.ExecuteNonQuery();
MessageBox.Show("Kayıt işlemi başarılı");
con.Close();
con.Close();
}
catch (Exception hata)
{
MessageBox.Show("Hata meydana geldi: " + hata.Message);
}
}
private void textBox4_TextChanged(object sender, EventArgs e)
{
}
}
}