❔ Get an entity with Sql data client
Hi,
Im trying to read some data with the sql data client and Im stuck.
The data looks like this: ID (uniqueidentifer, PK), Forename (nvarchar), Lastname (nvarchar), Birthday (datetime)
The code looks like this
The error message is:
Somebody has an idea what's wrong? That the script for the table
Im trying to read some data with the sql data client and Im stuck.
The data looks like this: ID (uniqueidentifer, PK), Forename (nvarchar), Lastname (nvarchar), Birthday (datetime)
The code looks like this
// Set the connection, command, and then execute the command with query and return the reader.
public static SqlOutput<DataTable> ExecuteReader(String connectionString, String commandText,
CommandType commandType = CommandType.Text, params SqlParameter[] parameters)
{
return Execute(cmd =>
{
using (SqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read()) // HERE THE ERROR IS HAPPENING
{
Console.WriteLine(String.Format("{0}", reader[0]));
}
}
return new DataTable();
}, commandType, parameters);
}
var result = SqlHelper.ExecuteReader(ConnectionString, input.script, System.Data.CommandType.Text, input.parameters.Select(x => // input.parameters = @[{'E48CC209-4D6A-4594-BD02-AE74DBCF82EA'}]
{
var p = new SqlParameter(x.Key, System.Data.SqlDbType.UniqueIdentifier);
p.Value = Guid.Parse(x.Value);
return p;
}).ToArray()); // Set the connection, command, and then execute the command with query and return the reader.
public static SqlOutput<DataTable> ExecuteReader(String connectionString, String commandText,
CommandType commandType = CommandType.Text, params SqlParameter[] parameters)
{
return Execute(cmd =>
{
using (SqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read()) // HERE THE ERROR IS HAPPENING
{
Console.WriteLine(String.Format("{0}", reader[0]));
}
}
return new DataTable();
}, commandType, parameters);
}
var result = SqlHelper.ExecuteReader(ConnectionString, input.script, System.Data.CommandType.Text, input.parameters.Select(x => // input.parameters = @[{'E48CC209-4D6A-4594-BD02-AE74DBCF82EA'}]
{
var p = new SqlParameter(x.Key, System.Data.SqlDbType.UniqueIdentifier);
p.Value = Guid.Parse(x.Value);
return p;
}).ToArray());The error message is:
System.Data.SqlClient.SqlException: "Error converting a character in "uniqueidentifer"."System.Data.SqlClient.SqlException: "Error converting a character in "uniqueidentifer"."Somebody has an idea what's wrong? That the script for the table