Click here to Skip to main content
16,008,942 members
Home / Discussions / Visual Basic
   

Visual Basic

 
SuggestionRe: encryption and decryption Pin
Richard Deeming14-Aug-15 4:41
mveRichard Deeming14-Aug-15 4:41 
QuestionRe: encryption and decryption Pin
Richard MacCutchan14-Aug-15 20:53
mveRichard MacCutchan14-Aug-15 20:53 
QuestionVS 2010 Combobox Not Populating Access Dropdown List Data Pin
VSForEver13-Aug-15 19:32
VSForEver13-Aug-15 19:32 
QuestionRe: VS 2010 Combobox Not Populating Access Dropdown List Data Pin
Paul Conrad7-Sep-15 7:25
professionalPaul Conrad7-Sep-15 7:25 
QuestionEntity framework connection string on SQL server and on SQL server Express Pin
satc12-Aug-15 5:37
satc12-Aug-15 5:37 
AnswerRe: Entity framework connection string on SQL server and on SQL server Express Pin
Wendelius12-Aug-15 6:00
mentorWendelius12-Aug-15 6:00 
GeneralRe: Entity framework connection string on SQL server and on SQL server Express Pin
satc12-Aug-15 6:40
satc12-Aug-15 6:40 
GeneralRe: Entity framework connection string on SQL server and on SQL server Express Pin
Wendelius12-Aug-15 7:01
mentorWendelius12-Aug-15 7:01 
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 

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.