- 27 Haz 2019
- 83
- 6
Arkadaşlar merhaba c# mysql bağlantısı yaparken böyle bi hata ile karşışaltım hatanın çözümünü anlatısanız sevinirim, c# yazılım dilinde yeniyim. Şimdiden herkese teşekkür ederim kodum ve hata aşağıdadır.
KODUM:
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 MySql.Data.MySqlClient;
namespace UserLogin
{
public partial class Form1 : Form
{
MySqlConnection con;
MySqlCommand cmd;
MySqlDataReader dr;
public Form1()
{
InitializeComponent();
con = new MySqlConnection("Server=localhost;Database=userslogin;user=root;Pwd=");
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
string user = textBox1.Text;
string pass = textBox2.Text;
cmd = new MySqlCommand();
con.Open();
cmd.Connection = con;
cmd.CommandText = "SELECT * FROM Bilgiler where usersName='" + textBox1.Text + "' AND usersPass='" + textBox2.Text + "'";
dr = cmd.ExecuteReader();
if (dr.Read())
{
MessageBox.Show("Giriş Başarılı.");
}
else
{
MessageBox.Show("Hatalı Kullanıcı Adı veya Şifre Girdiniz.");
}
}
}
}
HATA :
Windows-1252' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method
HATAYI VERDİĞ YER:
con.Open():
KODUM:
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 MySql.Data.MySqlClient;
namespace UserLogin
{
public partial class Form1 : Form
{
MySqlConnection con;
MySqlCommand cmd;
MySqlDataReader dr;
public Form1()
{
InitializeComponent();
con = new MySqlConnection("Server=localhost;Database=userslogin;user=root;Pwd=");
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
string user = textBox1.Text;
string pass = textBox2.Text;
cmd = new MySqlCommand();
con.Open();
cmd.Connection = con;
cmd.CommandText = "SELECT * FROM Bilgiler where usersName='" + textBox1.Text + "' AND usersPass='" + textBox2.Text + "'";
dr = cmd.ExecuteReader();
if (dr.Read())
{
MessageBox.Show("Giriş Başarılı.");
}
else
{
MessageBox.Show("Hatalı Kullanıcı Adı veya Şifre Girdiniz.");
}
}
}
}
HATA :
Windows-1252' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method
HATAYI VERDİĞ YER:
con.Open():