NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

/****** Script for SelectTopNRows command from SSMS ******/
SELECT TOP (1000) [OrderID]
,[CustomerID]
,[EmployeeID]
,[OrderDate]
,[RequiredDate]
,[ShippedDate]
,[ShipVia]
,[Freight]
,[ShipName]
,[ShipAddress]
,[ShipCity]
,[ShipRegion]
,[ShipPostalCode]
,[ShipCountry]
FROM [Northwind].[dbo].[Orders]



__________________________-
/****** Script for SelectTopNRows command from SSMS ******/
SELECT TOP (1000) [EmployeeID]
,[LastName]
,[FirstName]
,[Title]
,[TitleOfCourtesy]
,[BirthDate]
,[HireDate]
,[Address]
,[City]
,[Region]
,[PostalCode]
,[Country]
,[HomePhone]
,[Extension]
,[Photo]
,[Notes]
,[ReportsTo]
,[PhotoPath]
FROM [Northwind].[dbo].[Employees]




__

Select top 5 * from Products ORDER BY UnitPrice;

-----------------


using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Runtime.Intrinsics.Arm;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp4
{
internal class DataAdapter
{
SqlConnection conn;
SqlConnection conn1;
string connectionString = "Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=Northwind;Integrated Security=SSPI";
string connectionString1 = "Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=Practice6;Integrated Security=SSPI";
public DataAdapter()
{
conn = new SqlConnection(connectionString);
conn1 = new SqlConnection(connectionString1);
}
static void Main()
{
DataAdapter d = new DataAdapter();
// d.ReaddataInNorthwind();
// d.ReadDataInPracticeDB();
d.ReaddataTopFive();
}
public void ReaddataTopFive()
{
SqlDataReader rdr = null;
try
{
conn.Open();
//SqlCommand cmd = new SqlCommand("Select top 5 * from Customers", conn);
SqlDataAdapter d = new SqlDataAdapter("Select top 5 * from Products ORDER BY UnitPrice", conn);


DataSet ds = new DataSet();
d.Fill(ds, "data");




foreach (DataRow row in ds.Tables["data"].Rows)
{
Console.WriteLine(row["ProductName"]);

}



/* while (rdr.Read())
{
Console.WriteLine(rdr[1] + "tttt" + rdr[2]);
}*/

}
finally
{
if (rdr != null)
{
rdr.Close();
}
if (conn != null)
{
conn.Close();
}
}
}

public void ReaddataInNorthwind()
{
SqlDataReader rdr = null;
try
{
conn.Open();
//SqlCommand cmd = new SqlCommand("Select top 5 * from Customers", conn);
SqlDataAdapter d = new SqlDataAdapter("Select top 5 * from Employees", conn);
SqlDataAdapter d1 = new SqlDataAdapter("Select top 5 * from Orders", conn);

DataSet ds = new DataSet();
d.Fill(ds,"data");
d1.Fill(ds, "data1");
// DataRelation dr = new DataRelation("combined", ds.Tables["data"].Columns["EmployeeID"], ds.Tables["data1"].Columns["EmployeeID"]);
//ds.Relations.Add(dr);



foreach (DataRow row in ds.Tables["data"].Rows)
{
Console.WriteLine(row["ContactName"]);

}
Console.WriteLine();
foreach (DataRow row in ds.Tables["data1"].Rows)
Console.WriteLine(row["ProductName"]);


/* while (rdr.Read())
{
Console.WriteLine(rdr[1] + "tttt" + rdr[2]);
}*/

}
finally
{
if (rdr != null)
{
rdr.Close();
}
if (conn != null)
{
conn.Close();
}
}
}
public void ReadDataInPracticeDB()
{
SqlDataReader rdr = null;
try
{
conn.Open();
//SqlCommand cmd = new SqlCommand("Select top 5 * from Customers", conn);
SqlDataAdapter d = new SqlDataAdapter("Select * from Orders", conn1);
SqlDataAdapter d1 = new SqlDataAdapter("Select * from Product", conn1);

DataSet ds = new DataSet();
d.Fill(ds, "data");
d1.Fill(ds, "data1");
// DataRelation dr = ds.Relations.Add("combined data", ds.Tables["data"].Columns["CustomerID"], ds.Tables["data1"].Columns["CustomerID"]);



foreach (DataRow row in ds.Tables["data"].Rows)
{
Console.WriteLine(row["CustomerID"]);

}
Console.WriteLine();
foreach (DataRow row in ds.Tables["data1"].Rows)
Console.WriteLine(row["name"]);


/* while (rdr.Read())
{
Console.WriteLine(rdr[1] + "tttt" + rdr[2]);
}*/

}
finally
{
if (rdr != null)
{
rdr.Close();
}
if (conn != null)
{
conn.Close();
}
}
}




}
}



     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.