Hi chetan,
Refer below code.
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString))
{
string query = "SELECT O.OrderId, O.ShippedDate, C.CompanyName, C.City FROM Orders O INNER JOIN Customers C ON O.CustomerId = C.CustomerId WHERE OrderId = @OrderId";
using (SqlCommand cmd = new SqlCommand(query, con))
{
cmd.Parameters.AddWithValue("@OrderId", 10643);
con.Open();
cmd.ExecuteReader();
con.Close();
}
}
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Using con As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("constr").ConnectionString)
Dim query As String = "SELECT O.OrderId, O.ShippedDate, C.CompanyName, C.City FROM Orders O INNER JOIN Customers C ON O.CustomerId = C.CustomerId WHERE OrderId = @OrderId"
Using cmd As SqlCommand = New SqlCommand(query, con)
cmd.Parameters.AddWithValue("@OrderId", 10643)
con.Open()
cmd.ExecuteReader()
con.Close()
End Using
End Using
End Sub