Click here to Skip to main content
15,887,341 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Entity framework connection string on SQL server and on SQL server Express Pin
satc12-Aug-15 10:52
satc12-Aug-15 10:52 
GeneralRe: Entity framework connection string on SQL server and on SQL server Express Pin
Wendelius12-Aug-15 11:04
mentorWendelius12-Aug-15 11:04 
QuestionSQL server :Compressed string occupy more space than original string Pin
satc11-Aug-15 4:36
satc11-Aug-15 4:36 
AnswerRe: SQL server :Compressed string occupy more space than original string Pin
Richard MacCutchan11-Aug-15 5:37
mveRichard MacCutchan11-Aug-15 5:37 
GeneralRe: SQL server :Compressed string occupy more space than original string Pin
satc11-Aug-15 6:25
satc11-Aug-15 6:25 
GeneralRe: SQL server :Compressed string occupy more space than original string Pin
Richard MacCutchan11-Aug-15 6:53
mveRichard MacCutchan11-Aug-15 6:53 
GeneralRe: SQL server :Compressed string occupy more space than original string Pin
satc11-Aug-15 6:59
satc11-Aug-15 6:59 
AnswerRe: SQL server :Compressed string occupy more space than original string Pin
Richard Deeming11-Aug-15 7:29
mveRichard Deeming11-Aug-15 7:29 
satc wrote:
I have a large string that when is saved to VarChar(MAX) field , the size is 250 bytes.

250 bytes isn't a large string; varchar(max) can store up to 4,294,967,296 characters.

Compression typically works best on data with lots of repetitions. If every character of your string is a different character, the compressed data will always be larger than the input. If your string was just the same character repeated 250 times, the compressed data would be much smaller.

There's no need for a third-party library to compress strings in .NET - the System.IO.Compression namespace will do the job for you:
http://stackoverflow.com/a/2118959/124386[^]
C#
public static byte[] CompressString(string str)
{
    using (var output = new MemoryStream())
    using (var gzip = new DeflateStream(output, CompressionMode.Compress))
    using (var writer = new StreamWriter(gzip, System.Text.Encoding.UTF8))
    {
        writer.Write(str);
        return output.ToArray();
    }
} 
 
public static string DecompressString(byte[] input)
{
    using (var inputStream = new MemoryStream(input))
    using (var gzip = new DeflateStream(inputStream, CompressionMode.Decompress))
    using (var reader = new StreamReader(gzip, System.Text.Encoding.UTF8))
    {
        return reader.ReadToEnd();
    }
}




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


GeneralRe: SQL server :Compressed string occupy more space than original string Pin
satc11-Aug-15 7:58
satc11-Aug-15 7:58 
GeneralRe: SQL server :Compressed string occupy more space than original string Pin
Richard Deeming11-Aug-15 8:17
mveRichard Deeming11-Aug-15 8:17 
GeneralRe: SQL server :Compressed string occupy more space than original string Pin
satc11-Aug-15 10:06
satc11-Aug-15 10:06 
GeneralRe: SQL server :Compressed string occupy more space than original string Pin
Richard Deeming11-Aug-15 10:37
mveRichard Deeming11-Aug-15 10:37 
GeneralRe: SQL server :Compressed string occupy more space than original string Pin
satc11-Aug-15 11:42
satc11-Aug-15 11:42 
GeneralRe: SQL server :Compressed string occupy more space than original string Pin
Richard Deeming13-Aug-15 1:35
mveRichard Deeming13-Aug-15 1:35 
QuestionUpdate data in Report View control on a form Pin
Member 1129477510-Aug-15 11:27
Member 1129477510-Aug-15 11:27 
AnswerRe: Update data in Report View control on a form Pin
Richard Deeming11-Aug-15 4:25
mveRichard Deeming11-Aug-15 4:25 
GeneralRe: Update data in Report View control on a form Pin
Member 1129477511-Aug-15 4:49
Member 1129477511-Aug-15 4:49 
QuestionEntity Framework : Get original Values for each object's property Pin
satc10-Aug-15 3:42
satc10-Aug-15 3:42 
AnswerRe: Entity Framework : Get original Values for each object's property Pin
Eddy Vluggen10-Aug-15 5:29
professionalEddy Vluggen10-Aug-15 5:29 
GeneralRe: Entity Framework : Get original Values for each object's property Pin
satc10-Aug-15 5:47
satc10-Aug-15 5:47 
GeneralRe: Entity Framework : Get original Values for each object's property Pin
Eddy Vluggen10-Aug-15 5:53
professionalEddy Vluggen10-Aug-15 5:53 
AnswerRe: Entity Framework : Get original Values for each object's property Pin
Richard Deeming10-Aug-15 5:38
mveRichard Deeming10-Aug-15 5:38 
GeneralRe: Entity Framework : Get original Values for each object's property Pin
satc10-Aug-15 5:47
satc10-Aug-15 5:47 
GeneralRe: Entity Framework : Get original Values for each object's property Pin
Richard Deeming10-Aug-15 5:54
mveRichard Deeming10-Aug-15 5:54 
GeneralRe: Entity Framework : Get original Values for each object's property Pin
Eddy Vluggen10-Aug-15 5:51
professionalEddy Vluggen10-Aug-15 5:51 

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.