image column

  • How can I insert a row containing and image column in a table in sql 2000?

    Please guide me.

    I get this error when the file is more than 400K:

    A severe error occurred on the current command. The results, if any, should be discarded. A severe error occurred on the current command. The results, if any, should be discarded. - at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at FuncName(String strType, Byte[]& Buffer, Int32 FileLen, String DocumentID1, String FileContentType1)

    And the source is:

    try

    {

    conn = new SqlConnection();

    conn.ConnectionString=ConfigurationSettings.AppSettings.Get("SomeConnectionString");

    cmd = new SqlCommand("storedProcName goes here",conn);

    cmd.CommandType = System.Data.CommandType.StoredProcedure;

    DocumentIDParameter = new SqlParameter("@DocumentID_1",SqlDbType.Decimal, 0);

    DocumentIDParameter .Precision = 18;

    DocumentIDParameter.Value = DocumentID1;

    FileDataParameter = new SqlParameter("@FileData_10", SqlDbType.Image,FileLen);

    FileDataParameter.Value = Buffer;

    FileTypeParameter = new SqlParameter("@FileType_11", SqlDbType.Char,5);

    FileTypeParameter.Value= strType;

    FileSizeParameter = new SqlParameter("@FileSize_12", SqlDbType.BigInt);

    FileSizeParameter.Value=FileLen;

    FileContentTypeParameter = new SqlParameter("@FileContentType_13", SqlDbType.Char, 20);

    FileContentTypeParameter.Value=FileContentType1;

    cmd.Parameters.Add(DocumentIDParameter );

    cmd.Parameters.Add(FileDataParameter );

    cmd.Parameters.Add(FileTypeParameter );

    cmd.Parameters.Add(FileSizeParameter );

    cmd.Parameters.Add(FileContentTypeParameter );

    cmd.CommandTimeout=1000;

    conn.Open();

    cmd.ExecuteNonQuery();

    conn.Close();

    conn.Dispose();

    cmd.Dispose();

    }

    catch(Exception e)

    {

    Console.WriteLine(e.Message + " - " + e.StackTrace);

    Response.Write(e.Message + " - " + e.StackTrace);

    }

  • Please don't cross-post. It fragments replies and it just takes longer to solve the problem.

    No more replies here plz. Post answers on this thread :

    http://qa.sqlservercentral.com/Forums/Topic1109987-5-1.aspx

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply