Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Insert Image data into SQL server using IDbDataParameter
Message
From
20/06/2005 22:39:16
 
 
To
All
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
Insert Image data into SQL server using IDbDataParameter
Environment versions
Environment:
C# 1.1
OS:
Windows XP SP2
Database:
MS SQL Server
Miscellaneous
Thread ID:
01025023
Message ID:
01025023
Views:
145
Hi,

I am trying to insert a image data into sql server using MM .NET Framework, and I have tried different datatypes, and it did not work. The error tells me that "Line 1: Incorrect syntax near 'ADD_CACHE_ITEM'."

I tried to do the same thing with Sqlclient, and it worked. The difference is I used SqlDbType.Image instead of DbType.Binary or DbType.Object.

Any help is appreciated.


Here is the code that DONOT WORK:

//create a dataset
DateSet ds = GetDateSet();

byte[] serializedDS;

//serialize to binary
serializedDS = SerializationUtility.ToBytes (ds);

IDbDataParameter myParams;


myParams = this.CreateParameter("@VALUE",serializedDS);
myParams.DbType = DbType.Binary;
//myParams.DbType =DbType.Object;

this.ExecNonQuery ("ADD_CACHE_ITEM", myParams);

Here is the code that works:

//create a dataset
DateSet ds = GetDateSet();

byte[] serializedDS;

//serialize to binary
serializedDS = SerializationUtility.ToBytes (ds);

SqlCommand command = new SqlCommand ("ADD_CACHE_ITEM", connection);
command.CommandType = CommandType.StoredProcedure;

SqlParameter param0 = new SqlParameter( "@VALUE", serializedDS);
param0.SqlDbType = SqlDbType.Image;
command.Parameters.Add(param0);

command.ExecuteNonQuery ()
Next
Reply
Map
View

Click here to load this message in the networking platform