Click here to Skip to main content
15,887,683 members
Home / Discussions / C#
   

C#

 
GeneralRe: WCF - Client Wait Other Client Pin
dataminers18-Oct-09 20:53
dataminers18-Oct-09 20:53 
AnswerRe: WCF - Client Wait Other Client [modified] Pin
Mirko198018-Oct-09 23:08
Mirko198018-Oct-09 23:08 
Questioncustom control events Pin
teknolog12318-Oct-09 10:00
teknolog12318-Oct-09 10:00 
AnswerRe: custom control events Pin
DaveyM6918-Oct-09 10:22
professionalDaveyM6918-Oct-09 10:22 
GeneralRe: custom control events Pin
teknolog12318-Oct-09 12:01
teknolog12318-Oct-09 12:01 
GeneralRe: custom control events Pin
Dave Kreskowiak18-Oct-09 12:51
mveDave Kreskowiak18-Oct-09 12:51 
GeneralRe: custom control events Pin
teknolog12319-Oct-09 5:29
teknolog12319-Oct-09 5:29 
QuestionSave everything but the blob to DB Pin
JRivord18-Oct-09 8:46
JRivord18-Oct-09 8:46 
I have an application that is (should) save blobs in the database. It saves all the columns except the blob. I have been trying everything I can think of. If anyone has something to try, please let me know. I keep telling myself this should not be hard. Thanks in advance.

Here is the table (SQL Server 2005).

CREATE TABLE [dbo].[publication] (
    [id] INT IDENTITY(1,1) NOT NULL,
    [title] VARCHAR(50),
    [category] VARCHAR(50) NULL,
    [orig_file_name] VARCHAR(255) NULL,
    [publish_date] DATETIME NOT NULL DEFAULT(GETDATE()),
    [data] IMAGE NOT NULL,
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]


Here is the code.

public static int uploadPublication(string title, string originalFileName, DateTime publishDate, string category, System.IO.Stream publication)
{
    byte[] publicationData = new byte[publication.Length];
    publication.Read(publicationData, 0, Convert.ToInt32(publication.Length));
    SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ClubSiteDB"].ConnectionString);
    SqlCommand command = new SqlCommand("INSERT INTO publication (title, orig_file_name, publish_date, data, category) VALUES ( @title, @orig_file_name, @publish_date, @data, @category); select SCOPE_IDENTITY()", connection);
    SqlParameter param0 = new SqlParameter("@category", System.Data.SqlDbType.VarChar, 50);
    param0.Value = category;
    command.Parameters.Add(param0);
    SqlParameter param1 = new SqlParameter("@title", System.Data.SqlDbType.VarChar, 50);
    param1.Value = title;
    command.Parameters.Add(param1);
    SqlParameter param2 = new SqlParameter("@orig_file_name", System.Data.SqlDbType.VarChar, 255);
    param2.Value = originalFileName;
    command.Parameters.Add(param2);
    SqlParameter param3 = new SqlParameter("@publish_date", System.Data.SqlDbType.DateTime);
    param3.Value = publishDate;
    command.Parameters.Add(param3);
    SqlParameter param4 = new SqlParameter("@data", System.Data.SqlDbType.Image);
    param4.ParameterName = "data" ;
    param4.Value = publicationData;
    command.Parameters.Add(param4);
    connection.Open();
    object result = command.ExecuteScalar();
    connection.Close();
    if (result != null) 
    {
        return Convert.ToInt32(result);
    }
    else 
    {
        return 0;
    }
}

AnswerRe: Save everything but the blob to DB Pin
Not Active18-Oct-09 9:28
mentorNot Active18-Oct-09 9:28 
GeneralRe: Save everything but the blob to DB Pin
JRivord18-Oct-09 9:50
JRivord18-Oct-09 9:50 
GeneralRe: Save everything but the blob to DB Pin
Not Active18-Oct-09 10:18
mentorNot Active18-Oct-09 10:18 
QuestionBindingContext question Pin
HarrisonBrock18-Oct-09 7:41
HarrisonBrock18-Oct-09 7:41 
AnswerRe: BindingContext question Pin
dataminers18-Oct-09 11:16
dataminers18-Oct-09 11:16 
GeneralRe: BindingContext question Pin
HarrisonBrock18-Oct-09 12:42
HarrisonBrock18-Oct-09 12:42 
QuestionListboxes etc. on top of video Pin
lvq68418-Oct-09 7:29
lvq68418-Oct-09 7:29 
AnswerRe: Listboxes etc. on top of video Pin
Not Active18-Oct-09 9:26
mentorNot Active18-Oct-09 9:26 
GeneralRe: Listboxes etc. on top of video Pin
lvq68418-Oct-09 22:04
lvq68418-Oct-09 22:04 
QuestionTrying to send email... Pin
JollyMansArt18-Oct-09 6:50
JollyMansArt18-Oct-09 6:50 
AnswerRe: Trying to send email... Pin
Manas Bhardwaj18-Oct-09 9:19
professionalManas Bhardwaj18-Oct-09 9:19 
AnswerRe: Trying to send email... Pin
Not Active18-Oct-09 9:25
mentorNot Active18-Oct-09 9:25 
Questioncheck the text box string dynamically with database field Pin
Mangesh Tomar18-Oct-09 6:22
Mangesh Tomar18-Oct-09 6:22 
AnswerRe: check the text box string dynamically with database field Pin
Luc Pattyn18-Oct-09 11:11
sitebuilderLuc Pattyn18-Oct-09 11:11 
QuestionPass Excel.Application from Excel 2007 Custom Task Pane to Hosted PowerShell Pin
Uros Calakovic18-Oct-09 4:07
Uros Calakovic18-Oct-09 4:07 
QuestionSubReport in Win Form (RDLC) Pin
Abdul Rahman Hamidy18-Oct-09 3:20
Abdul Rahman Hamidy18-Oct-09 3:20 
AnswerRe: SubReport in Win Form (RDLC) Pin
Christopher Stratmann17-Apr-10 18:22
Christopher Stratmann17-Apr-10 18:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.