We help IT Professionals succeed at work.
Get Started

Method invocation failed because [System.Data.DataRow] does not contain a method named 'Split'.

bibi92
bibi92 asked
on
2,562 Views
Last Modified: 2016-01-20
Hello

I try to display starttime and endtime but error occurs Method invocation failed because [System.Data.DataRow] does not contain a method named 'Split'.

$server = "test\srv"
$sqlcmd = (
"DECLARE @ts_now bigint = (SELECT cpu_ticks/(cpu_ticks/ms_ticks)FROM sys.dm_os_sys_info); 

SELECT TOP(1) 
               convert(varchar, DATEADD(ms, -1 * (@ts_now - [timestamp]), GETDATE()))  +'|'+
			   convert(varchar, GETDATE()) +'|'+
               convert(varchar, SQLProcessUtilization)
FROM ( 
	  SELECT record.value('(./Record/@id)[1]', 'int') AS record_id, 
			record.value('(./Record/SchedulerMonitorEvent/SystemHealth/SystemIdle)[1]', 'int') AS [SystemIdle], 
			record.value('(./Record/SchedulerMonitorEvent/SystemHealth/ProcessUtilization)[1]','int') AS [SQLProcessUtilization],
			[timestamp] 
	  FROM ( 
			SELECT [timestamp], CONVERT(xml, record) AS [record] 
			FROM sys.dm_os_ring_buffers 
			WHERE ring_buffer_type = N'RING_BUFFER_SCHEDULER_MONITOR' 
			AND record LIKE N'%<SystemHealth>%') AS x 
	  ) AS y 
ORDER BY record_id DESC;"
)

$datasource = Invoke-SqlCmd -Query "$sqlcmd" -ServerInstance $server -QueryTimeout 200000
if ($datasource) {
foreach ($column in $datasource) {
$array_str = $column.Split("|")
$starttime = $array_str[0].Trim()
$endtime = $array_str[1].Trim()
$Title=$starttime + " to " + $endtime
$Title 
}
}		

Open in new window


Why ?

Thanks

Regards
Comment
Watch Question
CERTIFIED EXPERT
Most Valuable Expert 2013
Awarded 2012
Commented:
This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE