Reputation: 25
I want to copy all the data from the List to the table in the snowflake database.
Entity for Proposal
{
public string ServiceCode { get; set; }
public string ServiceDescription { get; set; }
public string ProviderGrossTariff { get; set; }
public string ProviderProposal { get; set; }
public string CleanedProposal { get; set; }
public string Notes { get; set; }
}
Table in the db:
create or replace TABLE TCT_WEBAPP.DBO.PROPOSALS_KEK (
SERVICECODE VARCHAR(255),
SERVICEDESCRIPTION VARCHAR(255),
PROVIDERGROSSTARIFF VARCHAR(255),
PROVIDERPROPOSAL VARCHAR(255),
CLEANEDPROPOSAL VARCHAR(255),
NOTES VARCHAR(255)
);
I convert my list to the DataTable using this method:
private DataTable ConvertToDataTable(List<Proposal> proposals)
{
DataTable dataTable = new DataTable();
dataTable.Columns.Add("ServiceCode");
dataTable.Columns.Add("ServiceDescription");
dataTable.Columns.Add("ProviderGrossTariff");
dataTable.Columns.Add("ProviderProposal");
dataTable.Columns.Add("CleanedProposal");
dataTable.Columns.Add("Notes");
foreach (var proposal in proposals)
{
dataTable.Rows.Add(
proposal.ServiceCode,
proposal.ServiceDescription,
proposal.ProviderGrossTariff,
proposal.ProviderProposal,
proposal.CleanedProposal,
proposal.Notes
);
}
return dataTable;
}
And then I'm trying to copy it to the table:
DataTable dataTable = ConvertToDataTable(proposals);
using (IDbCommand command = conn.CreateCommand())
{
// Set up a SQL command to execute stored procedure for bulk insert
command.CommandText = "$\"COPY INTO DBO.SOME_TABLE FROM (SELECT * FROM @dataTable)\"";
command.Parameters.Add(new SnowflakeDbParameter
{
ParameterName = "dataTable",
Value = dataTable
});
command.ExecuteNonQuery();
}
But then I get this error: Error: No corresponding Snowflake type for type AnsiString. SqlState: , VendorCode: 270053, QueryId:
Is anybody know what could be causing this error? Or may be you can suggest any other ways to copy data from the list to the db table?
Upvotes: 0
Views: 424