narasiman rao

narasiman rao

  • NA
  • 519
  • 769k

how to pass mutiple city id for each loop

Aug 26 2016 4:11 AM
 My code as follows

The below int_city id is as follows 1,2,4,6,8,11

int[] numbers = { 1, 2, 4, 6, 8, 11 };
foreach (int i in numbers)
{
System.Console.Write("{0} ", i);
}

string connectionString = ConfigurationManager.ConnectionStrings["OneTransportConnectionString"].ConnectionString;
SqlConnection sqlConnection = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand();
SqlDataReader reader;

cmd.CommandText = "select DISTINCT date_TripDate AS TripDate,traveltype.varchar_TravelTypeCode AS TripType,contactss.Value as Mobilenumber,time_TripTime AS ShiftTime,trip.int_VehicleTripID as RequestID,varchar_TravelerID AS AssociateID,(Associate_FirstName + Associate_LastName) AS AssociateName,Gender AS Gender,varchar_ProjectId AS ProjectID,varchar_ProjectName AS ProjectName,city.varchar_CityName AS City,placeee.varchar_PlaceName AS SourceArea,place.varchar_PlaceName AS DestinationArea,varchar_StatusDescription As Status,reason.varchar_ReasonDescription AS AppType"
cmd.CommandText += " from [OneC_988].[dbo].[988_Details_VehicleRequest] request"
cmd.CommandText += " join [OneC_988].[dbo].[988_Details_VehicleTrip] trip on request.int_VehicleRequestID=trip.int_VehicleRequestID"
cmd.CommandText += "and int_CityID = " " (pass that above city id function)

cmd.CommandType = CommandType.Text;
cmd.Connection = sqlConnection;
sqlConnection.Open();
reader = cmd.ExecuteReader();
sqlConnection.Close();

in int_cityid i want to pass the below thing

int[] numbers = { 1, 2, 4, 6, 8, 11 };
foreach (int i in numbers)
{
System.Console.Write(("{0} ", i);
}

the above one is pass multiple city in the and condition.

for that how to do in asp.net using c# 

Answers (1)