Bir web form oluşturup bunları ekliyoruz
GÖNDER butonuna girerek bunları yazıyrz:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
private SqlConnection tak;
protected void Page_Load(object sender, EventArgs e)
{
tak = new SqlConnection("Data Source=.\\SQLEXPRESS; Initial Catalog=Denemee; Integrated Security=true");
}
protected void Button1_Click(object sender, EventArgs e)
{
tak.Open();
SqlCommand kom = new SqlCommand("insert into tablo(ad,posta,tel,konu,msj) values (@ad,@posta,@tel,@konu,@msj)", tak);
kom.Parameters.AddWithValue("@ad", TextBox1.Text);
kom.Parameters.AddWithValue("@posta", TextBox2.Text);
kom.Parameters.AddWithValue("@tel", TextBox3.Text);
kom.Parameters.AddWithValue("@konu", TextBox4.Text);
kom.Parameters.AddWithValue("@msj", TextBox5.Text);
kom.ExecuteNonQuery();
tak.Close();
}
}
SQL SERVERİ ÇALIŞTIRIP DENEME ADINDA DATABASE OLUSTYRZ tablo ADINDA TABLO OLUSTUYORUZ.


Hiç yorum yok:
Yorum Gönder