04/05/2011 SQL Connection Dersi: Using Using Using Using Using Using Using Using Using Namespace Public Partial Class

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

04/05/2011

SQL CONNECTION DERSİ

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)


{

private void button1_Click(object sender, EventArgs e)


{
SqlConnection con = new SqlConnection("data source=YAZILIM1\\yazilim1;
initial catalog=Baglanti; Integrated Security=true");
con.Open();
SqlCommand cmd = new SqlCommand("SELECT KULLANICI FROM KullaniciGirisi",
con);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{

MessageBox.Show("Kullanıcı Adı: "+dr[0].ToString()+" "+"Şifre: "+dr[1].ToString());

dr.Close();
con.Close();

}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)


{

private void button1_Click(object sender, EventArgs e)


{
SqlConnection con = new SqlConnection("data source=YAZILIM1; initial
catalog=Baglandı; Integrated Security=true");
con.Open();
SqlCommand cmd = new SqlCommand("SELECT KULLANICI, SİFRE FROM
KullaniciGirisi", con);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
MessageBox.Show("Kullanıcı Adı: "+dr[0].ToString()+" "+"Şifre:
"+dr[1].ToString());

dr.Close();
con.Close();

private void button2_Click(object sender, EventArgs e)


{
KullaniciGirisi(textBox1.Text.ToString(), textBox2.Text.ToString());

public void KullaniciGirisi(string adi, string sifre)


{
SqlConnection con = new SqlConnection("data source=YAZILIM1; initial
catalog=Baglandı; Integrated Security=true");
con.Open();
SqlCommand cmd = new SqlCommand("SELECT KULLANICI, SİFRE FROM
KullaniciGirisi WHERE KULLANICI=@adi and SİFRE=@sifre", con);
cmd.Parameters.AddWithValue("@adi", adi);
cmd.Parameters.AddWithValue("@sifre", sifre);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
Form2 frm = new Form2();
frm.Show();
}
else
{
MessageBox.Show("Sifre veya gecersiz...!");
dr.Close();
con.Close();
}
}
}
}

SqlCommand cmd = new SqlCommand("SELECT KULLANICI, SİFRE FROM KullaniciGirisi WHERE


KULLANICI Collate SQL_Latin1_General_CP1254_CS_AS = @adi and SİFRE Collate
SQL_Latin1_General_CP1254_CS_AS =@sifre", con);

CASE SENSITIVE OZELLİĞİNİ

Collate SQL_Latin1_General_CP1254_CS_AS = @adi and SİFRE Collate


SQL_Latin1_General_CP1254_CS_AS =@sifre

You might also like