ByWasco
Kilopat
- Katılım
- 24 Ocak 2015
- Mesajlar
- 236
Daha fazla
- Cinsiyet
- Erkek
C# ile Microsoft SQL Server Management Studio 18 arasında bağlantı hatası aliyorum.
Fomra giriş ve kayıt olma özelliği ekledim veri tabanını yapiyorum, ne yazik ki veri çekmek için hata aliyorum.
Yaptıklarım;
Çalıştırdan services.msc yazarak hizmetlerden SQL serveri bulmaktı. Normal de çalışıyor ama ben durdurup tekrar çalıştırdım sorun çözülmedi.
Vereceğim linkteki tüm adımları teker teker denedim sorun yine çözülmedi. Link
Aşağıya aldığım hataların fotoğraflarını atiyorum.
[CODE title="C# SQL"]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; //SQL Kütüphanesi
namespace SQL2
{
public partial class Form1 : Form
{
SqlConnection connection=new SqlConnection("Data Source=DESKTOP-MTQ3JK4\\Durdu; Initial Catalog=Girispaneli;Integrated Security=True");
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
bool isThere;
private void button1_Click(object sender, EventArgs e)
{
string username = textBox1.Text;
string pass = textBox2.Text;
connection.Open();
SqlCommand command = new SqlCommand("Select *from Youtube", connection);
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
if (username==reader["username"] && pass==reader["pass"])
{
isThere = true;
break;
}
else
{
isThere = false;
}
}
if (isThere)
{
MessageBox.Show("Başarıyla giriş yaptınız !", "Program");
}
else
{
MessageBox.Show("Giriş yapamadınız !", "Program");
}
}
}
}
[/CODE]
[CODE title="C# Sql başka kod"]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; //SQL Bağlantısı için gerek kod.
namespace Admin_Panel_Girişi
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
static string constring = ("Data Source=DESKTOP-MTQ3JK4\\Durdu;Initial Catalog=Kisiler;Integrated Security=True"); // SQL Veri Yolu.
SqlConnection connect = new SqlConnection(constring); //SQL Bağlantı Kodu.
private void button1_Click(object sender, EventArgs e)
{
Application.Exit();// Programdan Çıkış Kodu.
}
private void button2_Click(object sender, EventArgs e)
{
{
}
try // Üye Olma Panel Kısım Ayarlamaları.
{
if (connect.State == ConnectionState.Closed)
connect.Open();
string kayit = "insert into bilgi (kullanıcı_adi,ad_soyad,eposta) values(@kullanıcı_adi,ad_soyad,@eposta)";
SqlCommand komut = new SqlCommand(kayit, connect);
komut.Parameters.AddWithValue("@kullanıcı_adi", kadi.Text);
komut.Parameters.AddWithValue("@ad_soyad", adsoyad.Text);
komut.Parameters.AddWithValue("@eposta", eposta.Text);
komut.ExecuteNonQuery();
connect.Close();
MessageBox.Show("Kayıt Başarılı");
}
catch (Exception hata)
{
MessageBox.Show("Hata Meydana Geldi" + hata.Message);
}
if (kadi.Text == "") //Textbox Boş Geçilemez Kodu.
{
provider.SetError(kadi, "Bu alan boş geçilemez");
}
if (adsoyad.Text == "") //Textbox Boş Geçilemez Kodu.
{
provider.SetError(adsoyad, "Bu alan boş geçilemez");
}
if (eposta.Text == "") //Textbox Boş Geçilemez Kodu.
{
provider.SetError(eposta, "Bu alan boş geçilemez");
}
}
[/CODE]
Fomra giriş ve kayıt olma özelliği ekledim veri tabanını yapiyorum, ne yazik ki veri çekmek için hata aliyorum.
Yaptıklarım;
Çalıştırdan services.msc yazarak hizmetlerden SQL serveri bulmaktı. Normal de çalışıyor ama ben durdurup tekrar çalıştırdım sorun çözülmedi.
Vereceğim linkteki tüm adımları teker teker denedim sorun yine çözülmedi. Link
Aşağıya aldığım hataların fotoğraflarını atiyorum.
[CODE title="C# SQL"]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; //SQL Kütüphanesi
namespace SQL2
{
public partial class Form1 : Form
{
SqlConnection connection=new SqlConnection("Data Source=DESKTOP-MTQ3JK4\\Durdu; Initial Catalog=Girispaneli;Integrated Security=True");
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
bool isThere;
private void button1_Click(object sender, EventArgs e)
{
string username = textBox1.Text;
string pass = textBox2.Text;
connection.Open();
SqlCommand command = new SqlCommand("Select *from Youtube", connection);
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
if (username==reader["username"] && pass==reader["pass"])
{
isThere = true;
break;
}
else
{
isThere = false;
}
}
if (isThere)
{
MessageBox.Show("Başarıyla giriş yaptınız !", "Program");
}
else
{
MessageBox.Show("Giriş yapamadınız !", "Program");
}
}
}
}
[/CODE]
[CODE title="C# Sql başka kod"]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; //SQL Bağlantısı için gerek kod.
namespace Admin_Panel_Girişi
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
static string constring = ("Data Source=DESKTOP-MTQ3JK4\\Durdu;Initial Catalog=Kisiler;Integrated Security=True"); // SQL Veri Yolu.
SqlConnection connect = new SqlConnection(constring); //SQL Bağlantı Kodu.
private void button1_Click(object sender, EventArgs e)
{
Application.Exit();// Programdan Çıkış Kodu.
}
private void button2_Click(object sender, EventArgs e)
{
{
}
try // Üye Olma Panel Kısım Ayarlamaları.
{
if (connect.State == ConnectionState.Closed)
connect.Open();
string kayit = "insert into bilgi (kullanıcı_adi,ad_soyad,eposta) values(@kullanıcı_adi,ad_soyad,@eposta)";
SqlCommand komut = new SqlCommand(kayit, connect);
komut.Parameters.AddWithValue("@kullanıcı_adi", kadi.Text);
komut.Parameters.AddWithValue("@ad_soyad", adsoyad.Text);
komut.Parameters.AddWithValue("@eposta", eposta.Text);
komut.ExecuteNonQuery();
connect.Close();
MessageBox.Show("Kayıt Başarılı");
}
catch (Exception hata)
{
MessageBox.Show("Hata Meydana Geldi" + hata.Message);
}
if (kadi.Text == "") //Textbox Boş Geçilemez Kodu.
{
provider.SetError(kadi, "Bu alan boş geçilemez");
}
if (adsoyad.Text == "") //Textbox Boş Geçilemez Kodu.
{
provider.SetError(adsoyad, "Bu alan boş geçilemez");
}
if (eposta.Text == "") //Textbox Boş Geçilemez Kodu.
{
provider.SetError(eposta, "Bu alan boş geçilemez");
}
}
[/CODE]