Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hello !

there is error from sql.

An exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll but was not handled in user code

Additional information: Incorrect syntax near the keyword 'into'.

C#
protected void Button1_Click(object sender, EventArgs e)
{


    if (string.IsNullOrWhiteSpace(txtKullan.Text + txtSifre.Text + txtMail.Text))
    {
        uyari.Text = "Tüm alanları doldurmak zorundasınız";
        return;

    }

    SqlConnection baglanti = new SqlConnection("Data Source=RMZN;Initial Catalog=veri;Integrated Security=True;");
    baglanti.Open();

    SqlCommand cmd = new SqlCommand("Instert into Uyeler(UyeAdi,UyeSifre,UyeMail) values ('"+txtKullan.Text+"','"+txtSifre.Text+"','"+txtMail.Text+"')",baglanti);
    cmd.ExecuteNonQuery();
    txtKullan.Text = "";
    txtSifre.Text = "";
    txtMail.Text = "";
    uyari.Text = "Kayıt işlemi başarıyla tamamlandı giriş yapabilirsiniz.";


}
Posted
Updated 14-Jun-15 11:59am
v2
Comments
CHill60 14-Jun-15 17:42pm    
You were shown how to use parameterized queries in a solution to your previous question on this same piece of code!
Ahmet Yön 14-Jun-15 18:04pm    
i changed them .

try
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
conn.Open();
string insertQuery = "insert into veri (UyeAdi, UyeSifre, UyeMail) values (@KU, @SI, @MA)";
SqlCommand com = new SqlCommand(insertQuery, conn);
com.Parameters.AddWithValue("@KU", txtKullan.Text);
com.Parameters.AddWithValue("@SI", txtSifre.Text);
com.Parameters.AddWithValue("@MA", txtMail.Text);

com.ExecuteNonQuery();
//uyari.Text = "Kayıt başarıyla tamamlandı.";
//Response.Redirect("default3.aspx");
uyari.Text = "Kayıt başarıyla tamamlandı";
conn.Close();

}
catch (Exception ex)
{

Response.Write("Error" + ex.ToString());
}

Response.Write("işlem tamamlandı");

}

1 solution

It's "insert", not "Instert".

Also use parameterised queries, your code is open to SQL injection attacks.

SQL Injection Attacks and Some Tips on How to Prevent Them[^]
 
Share this answer
 
Comments
Ahmet Yön 14-Jun-15 17:50pm    
its only homework i wll not upload it any server :) can u help me again ? i hace some prblems and i have to give this project my teacher
PIEBALDconsult 14-Jun-15 18:12pm    
That's no excuse. Do it the right way every time. It should become a habit.
Ahmet Yön 14-Jun-15 19:01pm    
okay i wll do it :) thanks a lot.
Ahmet Yön 14-Jun-15 18:05pm    
https://www.youtube.com/watch?v=QAd-DbP4U8g ineed a project like that and this tuesday i have to give it to my teacher
Sergey Alexandrovich Kryukov 15-Jun-15 0:11am    
Sure, a 5.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900