Horje
c# Select MSSQL Code Example
c# sql select
SqlConnection conn = new SqlConnection("Data Source=;Initial Catalog=;Persist Security Info=True;User ID=;Password=");
conn.Open();

SqlCommand command = new SqlCommand("Select id from [table1] where name=@zip", conn);
command.Parameters.AddWithValue("@zip","india");
 // int result = command.ExecuteNonQuery();
using (SqlDataReader reader = command.ExecuteReader())
{
  if (reader.Read())
  {
     Console.WriteLine(String.Format("{0}",reader["id"]));
   }
}

conn.Close();
c# Select MSSQL
DataSet ds = new DataSet();
//https://www.oracle.com/webfolder/technetwork/tutorials/obe/db/dotnet/ODPNET_Core_get_started/index.html
using (SqlConnection con = new SqlConnection(connectionstr))
{
    using (SqlCommand cmd = con.CreateCommand())
    {
        con.Open();
        cmd.CommandText = "select * from master.sys.server_principals";
        SqlDataAdapter adapter = new SqlDataAdapter(cmd);
        adapter.Fill(ds);
    }
}




Csharp

Related
how to save a dictionary as a csv file in c# Code Example how to save a dictionary as a csv file in c# Code Example
how to check if the value is alphabet only in c# Code Example how to check if the value is alphabet only in c# Code Example
checking if a list contains a value unity Code Example checking if a list contains a value unity Code Example
how to check that string has only alphabet in c# Code Example how to check that string has only alphabet in c# Code Example
how to locate a specific element in a list c# Code Example how to locate a specific element in a list c# Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
11