Search
 
SCRIPT & CODE EXAMPLE
 

SQL

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();
Comment

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);
    }
}
Comment

c# Select MSSQL


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();

Comment

PREVIOUS NEXT
Code Example
Sql :: is between inclusive or exclusive sql 
Sql :: sql add two values together 
Sql :: sql distinct with count 
Sql :: SQL Auto Increment Primary Key - SQL Server 
Sql :: update using case in mysql 
Sql :: convert money to varchar sql server 
Sql :: Assign value to var in SQL 
Sql :: sql common columns 
Sql :: postgres set column equal to another 
Sql :: lowest salary in sql 
Sql :: login to mysql database 
Sql :: How do I add a user to a postgres database? cli 
Sql :: mysql update with subquery 
Sql :: mysql drop database 
Sql :: postgres get defined index in table 
Sql :: store select query result in variable sql server 
Sql :: select into temp table 
Sql :: oracle select first row order by 
Sql :: database dump mysql command 
Sql :: mysql query dates between two dates 
Sql :: kill a pid redshift 
Sql :: how to copy data in sql 
Sql :: mysql update with join 
Sql :: postgres set null 
Sql :: mysql find duplicates in same table 
Sql :: how to delete the rows with null values in mysql 
Sql :: get time component of datetime sql 
Sql :: drop sequence 
Sql :: mysql collation for all languages 
Sql :: between from sql 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =