Getting datarow values into a string?

You need to specify which column of the datarow you want to pull data from. Try the following: StringBuilder output = new StringBuilder(); foreach (DataRow rows in results.Tables[0].Rows) { foreach (DataColumn col in results.Tables[0].Columns) { output.AppendFormat(“{0} “, rows[col]); } output.AppendLine(); }

How to check if Datarow value is null

Check if the data column is not null with DataRow.IsNull(string columnName) if (!row.IsNull(“Int64_id”)) { // here you can use it safety long someValue = (long)row[“Int64_id”]; } There are overloads for it using the index of the column or if you have the instance of the DataColumn. If you are sure about the index, use the … Read more

Find row in datatable with specific id

Make a string criteria to search for, like this: string searchExpression = “ID = 5” Then use the .Select() method of the DataTable object, like this: DataRow[] foundRows = YourDataTable.Select(searchExpression); Now you can loop through the results, like this: int numberOfCalls; bool result; foreach(DataRow dr in foundRows) { // Get value of Calls here result … Read more

get index of DataTable column with name

You can use DataColumn.Ordinal to get the index of the column in the DataTable. So if you need the next column as mentioned use Column.Ordinal + 1: row[row.Table.Columns[“ColumnName”].Ordinal + 1] = someOtherValue; Warning: This code returns the next column, so the one after ColumnName, as requested in the question.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)