I want to search multiple using only one textbox, is that possible?
for example i want input 20712 20713 20714 20715 in my textbox to be search and viewed it the datagridview. TIA
Please see below query below that i used to show data in my datagridview.
What I have tried:
string TurNum = txtTurName.Text;
try
{
if (TurNum == "")
{
MessageBox.Show("Please Eneter SCADA ParkName");
}
else if (TurNum == txtTurName.Text)
{
ConnVDC.openConnection();
ConnVDC.sql = ("SELECT DISTINCT t2.turbinenumber, gdcipaddress AS TurbineIPAddress, parkname, t2.sbuname AS Region, t2.countryname_park, t2.scadaparkname, t2.scadaipaddress, t2.datacentername, t2.parkgeographicaltimezoneindex, t2.sapfunctionallocation, t2.highestcontract, t2.turbinename, newestvmp10mindatalocal, newesttac10mindatalocal, newestolt10mindatalocal, CASE WHEN newestvmp10mindatalocal IS NULL THEN Datediff(day, newesttac10mindatalocal, Getdate()) WHEN newestvmp10mindatalocal IS NOT NULL THEN Datediff(day, newestvmp10mindatalocal, Getdate()) end AS[No: of days], CASE WHEN newestvmp10mindatalocal IS NULL AND Datediff(day, newesttac10mindatalocal, Getdate()) > 90 THEN '> 90 days' WHEN newestvmp10mindatalocal IS NOT NULL AND Datediff(day, newestvmp10mindatalocal, Getdate()) > 90 THEN '> 90 days' WHEN newestvmp10mindatalocal IS NULL AND Datediff(day, newesttac10mindatalocal, Getdate()) < 1 THEN 'Uptodate' WHEN newestvmp10mindatalocal IS NOT NULL AND Datediff(day, newestvmp10mindatalocal, Getdate()) < 1 THEN 'Uptodate' WHEN newestvmp10mindatalocal IS NULL AND Datediff(day, newesttac10mindatalocal, Getdate()) < 3 THEN '1 - 2 days' WHEN newestvmp10mindatalocal IS NOT NULL AND Datediff(day, newestvmp10mindatalocal, Getdate()) < 3 THEN '1 - 2 days' WHEN newestvmp10mindatalocal IS NULL AND Datediff(day, newesttac10mindatalocal, Getdate()) < 8 THEN '3 - 7 days' WHEN newestvmp10mindatalocal IS NOT NULL AND Datediff(day, newestvmp10mindatalocal, Getdate()) < 8 THEN '3 - 7 days' WHEN newestvmp10mindatalocal IS NULL AND Datediff(day, newesttac10mindatalocal, Getdate()) < 16 THEN '8 - 15 days' WHEN newestvmp10mindatalocal IS NOT NULL AND Datediff(day, newestvmp10mindatalocal, Getdate()) < 16 THEN '8 - 15 days' WHEN newestvmp10mindatalocal IS NULL AND Datediff(day, newesttac10mindatalocal, Getdate()) < 31 THEN '16 - 30 days' WHEN newestvmp10mindatalocal IS NOT NULL AND Datediff(day, newestvmp10mindatalocal, Getdate()) < 31 THEN '16 - 30 days' WHEN newestvmp10mindatalocal IS NULL AND Datediff(day, newesttac10mindatalocal, Getdate()) < 61 THEN '31 - 60 days' WHEN newestvmp10mindatalocal IS NOT NULL AND Datediff(day, newestvmp10mindatalocal, Getdate()) < 61 THEN '31 - 60 days' WHEN newestvmp10mindatalocal IS NULL AND Datediff(day, newesttac10mindatalocal, Getdate()) < 91 THEN '61 - 90 days' WHEN newestvmp10mindatalocal IS NOT NULL AND Datediff(day, newestvmp10mindatalocal, Getdate()) < 91 THEN '61 - 90 days' end AS[Period of Days], newestturbineeventlocal, parkname, t2.sbuname, t2.countryname_park, t2.maincontrollername, t2.datacentername, t2.soayieldcalculationstart, t2.soayieldcalculationend, t2.warrantyinservicecontractstart, t2.warrantyinservicecontractend, t2.oldserialnumber FROM fct.turbinehasdata t1 INNER JOIN dim.turbine t2 ON t1.dt1turbineid = t2.dt1turbineid WHERE Getdate() BETWEEN t2.validfrom AND t2.validto AND t2.turbinenumber IN ('" + TurNum +"')");
ConnVDC.cmd.CommandType = CommandType.Text;
ConnVDC.cmd.CommandText = ConnVDC.sql;
ConnVDC.da = new SqlDataAdapter(ConnVDC.cmd);
ConnVDC.dt = new DataTable();
ConnVDC.da.Fill(ConnVDC.dt);
myDataGrid.AutoGenerateColumns = true;
myDataGrid.ItemsSource = ConnVDC.dt.DefaultView;
ConnVDC.closeConnection();
MessageBox.Show("If park is not yet added in GDA Servers. ScadaParkname, SCADAIPaddress and datacenter should be a Null value (N/A)", "Note");
}
}
catch (Exception ex)
{
MessageBox.Show("The System failed to establish a connection." + Environment.NewLine +
"Descriptions: " + ex.Message.ToString(), "SQL Server Connectivity Issue");
}