Have following:myCommand.Parameters.Add(New Data.SqlClient.SqlParameter("@Job", Data.SqlDbType.Char, 20)).Value = TextBox3.Text
ALTER PROCEDURE [dbo].[sp_goLabor_get_batch_details] @Owner char(50),select distinct(Event.BatchGuid), Batch.Name as BatchName, Batch.ReportDate as ReportDate, Job.CompanyJobId as JobNumber, EventStatusType.Name as ReportStatusfrom [VGIWPSQL2].goLabor30.dbo.event inner join [VGIWPSQL2].goLabor30.dbo.Batch on Batch.BatchGuid = Event.BatchGuid inner join [VGIWPSQL2].goLabor30.dbo.Job on Job.JobGuid = Event.JobGuid inner join [VGIWPSQL2].goLabor30.dbo.EventStatusType on EventStatusType.EventStatusTypeGuid = Event.EventStatus inner join [VGIWPSQL2].goLabor30.dbo.Account on Account.AccountGuid = Event.AccountGuidwhere (@Owner IS Null or Account.Username = @Owner) and (@DateFrom IS Null OR Batch.Reportdate >= @DateFrom)and (@DateTo IS Null OR Batch.ReportDate <= @DateTo) and (@Job IS Null or Job.CompanyJobId = @Job) and (EventStatusType.Name = @Status)order by Batch.Name
If TextBox3 is not filled in then my sql query does not work on @Job. If I fill in a job number in Textbox3 it works fine.