如何将varbinary dat插入sqlserverce

时间:2011-06-06 06:50:22

标签: c# asp.net sql-server-ce

我已经开发了一个小的asp.net应用程序来将数据存储到sqlserverce中,如何在sqlserver中设置varbinary(max)ce.i已经编写了这样的代码

    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:");

当我尝试向此插入数据时,它显示错误,如

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

有什么不对请帮助我......

1 个答案:

答案 0 :(得分:1)

使用映像数据类型,SQL Server Compact不支持varbinary(MAX)