I am reading excel and saving output in dt.
I want to pass all the values in dt comma-separated string to execute sql query
i am using below approach
DirectoryList=(from row in directoryNumberDt.AsEnumerable select Convert.ToString(row.Item(“Telephone Number”))).ToList
strDirectoryNumber=String.Join(“,”,DirectoryList).Trim
It was working fine but now iam getting issue like below:
Use this below code to remove extra commas, @thima
System.Text.RegularExpressions.Regex.Replace(YourString,“,{2,}”,“,”, RegexOptions.Multiline).
Hope this may help you