narasiman rao

narasiman rao

  • NA
  • 519
  • 767.1k

when i run the code shows error

Aug 25 2016 6:58 AM
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,";
cmd.CommandText = cmd +"varchar_TravelerID AS AssociateID,(Associate_FirstName + Associate_LastName) AS AssociateName, Gender AS Gender,varchar_ProjectId AS ProjectID,varchar_ProjectName AS ProjectName,";
 
cmd.CommandText = cmd +"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 = cmd +"from [OneC_988].[dbo].[988_Details_VehicleRequest] request";
cmd.CommandText = cmd +"join [OneC_988].[dbo].[988_Details_VehicleTrip] trip on request.int_VehicleRequestID=trip.int_VehicleRequestID";
cmd.CommandText = cmd + "and int_CityID ='8'";
cmd.CommandText = cmd +"join [OneC_988].[dbo].[988_Details_TripSheet] sheet on trip.int_VehicleTripID=sheet.int_VehicleTripID";
cmd.CommandText = cmd +"join [CentralRepository].[dbo].[vw_CentralRepository_Associate_Details] AD on trip.varchar_TravelerID=AD.Associate_ID";
cmd.CommandText = cmd +"left join [CentralRepository].[dbo].[vw_CentralRepository_Contacts] contactss on contactss.Associate_ID = trip.varchar_TravelerID and contactss.Contact_Type='MBL1'";
cmd.CommandText = cmd +"join [OneC_988].[dbo].[988_Master_Place] place on place.int_PlaceID=trip.int_TripDestinationID";
cmd.CommandText = cmd +"join [OneC_988].[dbo].[988_Master_Place] placeee on placeee.int_PlaceID=trip.int_TripSourceID";
cmd.CommandText = cmd +"join [988_Master_City] city on request.int_CityID=city.int_CityID";
cmd.CommandText = cmd +"join [OneC_988].[dbo].[988_Master_TravelType] traveltype on traveltype.int_TravelTypeID=trip.int_TravelTypeID";
cmd.CommandText = cmd +"join [OneC_988].[dbo].[988_Master_Reason] reason on reason.int_ReasonID=request.int_ReasonID";
cmd.CommandText = cmd +"join [OneC_988].[dbo].[988_Master_Status] status on status.int_StatusID=trip.int_TripStatusID";
cmd.CommandText = cmd + "where date_TripDate ='2016-08-24' and trip.int_TripStatusID not in (0)";
cmd.CommandType = CommandType.Text;
cmd.Connection = sqlConnection;
sqlConnection.Open();
reader = cmd.ExecuteReader();
Console.WriteLine("test");
sqlConnection.Close();
 
when i run the above shows error as follows 
  Incorrect syntax near '='. 
  The above error shows in below line as follows   
 reader = cmd.ExecuteReader();
 
please help me what is the mistake in my above query
 
 

Answers (3)