Victor Athoti.
Victor Athoti.

Reputation: 831

how to insert varbinary dat into sqlserverce

I have develop a small asp.net application to store the data into sqlserverce ,How can i set varbinary(max) in sqlserver ce.i have wrote the code like this

    string filepath = Server.MapPath("~/App_Data/") + txtuname.Text + ".sdf";
    SqlCeConnection conn = new SqlCeConnection(@"Data Source=" + filepath);
    conn.Open();
    SqlCeCommand cmdCreate = new SqlCeCommand("CREATE TABLE Mybusinessapp_Pictures (Id int IDENTITY(1,1)PRIMARY KEY, Name nchar(50),Description nvarchar(500),Data varbinary(510),ImageUrl nvarchar(500))", conn);
    cmdCreate.ExecuteNonQuery();
    MessageBox.Show("Table created:");

When I try to insert data into this it showing error like

The conversion is not supported. [ Type to convert from (if known) = nvarchar, Type to convert to (if known) = varbinary ]

What is was the wrong please help me...

Upvotes: 3

Views: 1411

Answers (1)

ErikEJ
ErikEJ

Reputation: 41769

Use the image data type, varbinary(MAX) is not suported by SQL Server Compact

Upvotes: 1

Related Questions