1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[SQL] how to build a SQL connection using C# in Visual Studio 2017?

Discussão em 'Outras Linguagens' iniciado por Stack, Novembro 5, 2024 às 14:12.

  1. Stack

    Stack Membro Participativo

    I've always used Oledb Connection. but now I need to connect with my Database via Sql connection yet I don't know how to do so, can some one provide me an example of a database connected with sql connection?

    this code needs a sql connection to be done successfully.

    protected void Button1_Click(object sender, EventArgs e)
    {
    string st = this.TextBox1.Text;
    string sqlstr2 = "select * from hsinfo WHERE rname='"+st+ "'";

    SqlCommand cmd = new SqlCommand(sqlstr2,);
    using (SqlDataReader rd = cmd.ExecuteReader())
    {
    this.Label1.Text = rd["rmail"].ToString();
    }
    }

    Continue reading...

Compartilhe esta Página