Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need know how to declare VABINAY(MAX) in C#

What I have tried:

How can I declare VARBINARY(MAX) in C#?
Please help me
Posted
Updated 25-Mar-22 8:11am
Comments
Richard MacCutchan 29-Dec-21 5:33am    
What do you mean? VARBINARY is an SQL data type, nothing to do with C#.

You don't: you cast the VARBINARY field that SQL returns from a SELECT to a byte[], and supply a byte[] as a parameter when you INSERT or UPDATE.
 
Share this answer
 
Comments
Maciej Los 29-Dec-21 12:56pm    
5ed!
 
Share this answer
 
If you are doing code-first EF Migrations to create your SQL tables, this works for me:
C#
public byte[] MyImage { get; set; }

This is what gets written by the migrationBuilder:
C#
<pre>MyImage = table.Column<byte[]>(type: "varbinary(max)", nullable: false)

I hope this helps someone.
 
Share this answer
 
For your future reference of use SQL Server Data Type Mappings:
SQL Server Data Type Mappings (ADO.NET) | Microsoft Docs[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900