Click here to Skip to main content
15,901,122 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# working with Sapces in registry Keys Pin
User 66583-Jul-08 4:55
User 66583-Jul-08 4:55 
GeneralRe: C# working with Sapces in registry Keys Pin
Planker3-Jul-08 7:31
Planker3-Jul-08 7:31 
QuestionHow to disbale outlook security warnings while sending mails Pin
sivasankar anumula3-Jul-08 4:45
sivasankar anumula3-Jul-08 4:45 
AnswerRe: How to disbale outlook security warnings while sending mails Pin
MumbleB3-Jul-08 6:50
MumbleB3-Jul-08 6:50 
QuestionWebclient.DownloadFilesAsync issue Pin
Reason Man3-Jul-08 4:17
Reason Man3-Jul-08 4:17 
AnswerRe: Webclient.DownloadFilesAsync issue Pin
Michael90003-Jul-08 8:03
Michael90003-Jul-08 8:03 
AnswerRe: Webclient.DownloadFilesAsync issue Pin
Anthony Mushrow3-Jul-08 8:34
professionalAnthony Mushrow3-Jul-08 8:34 
QuestionC# Save data from DB (BLOB) Problem ... 1Kb is missing [modified] Pin
countnazgul3-Jul-08 4:13
countnazgul3-Jul-08 4:13 
Hello,
I've got very odd problem.
I use windows application to store files in data base (MySql) and then to extract this files from data base and save it on hdd. But when i save them back to hdd tihs files are 1Kb less from original file. When i insert pictures this 1kb obviously is not imported and the pictures is shown. But other files when try to be opened is corrupted or if they open some error message is shown.
So the code that i use to save file in DB is:

MySqlConnection con = new MySqlConnection("SERVER=localhost;" +
     "DATABASE=db;" +
     "UID=user;" +
     "PASSWORD=root;");

 MySqlDataAdapter da = new MySqlDataAdapter("Select * From test", con);
 MySqlCommandBuilder MyCB = new MySqlCommandBuilder(da);
 DataSet ds = new DataSet("test");

 da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
 FileStream fs = new FileStream(@"C:\image.rar", FileMode.OpenOrCreate, FileAccess.Read);

 byte[] MyData = new byte[fs.Length];
 fs.Read(MyData, 0, System.Convert.ToInt32(fs.Length));

 fs.Close();

 da.Fill(ds, "test");

 DataRow myRow;
 myRow = ds.Tables["test"].NewRow();

 myRow["id"] = "12";
 myRow["blobdata"] = MyData;
 ds.Tables["test"].Rows.Add(myRow);
 da.Update(ds, "test");

 con.Close();


The code that extract files from database and save them to hdd is:

MySqlConnection con = new MySqlConnection("SERVER=localhost;" +
    "DATABASE=db;" +
    "UID=user;" +
    "PASSWORD=root;");

MySqlDataAdapter da = new MySqlDataAdapter("Select * From test where id = 12", con);
MySqlCommandBuilder MyCB = new MySqlCommandBuilder(da);
DataSet ds = new DataSet("test");

byte[] MyData;

da.Fill(ds, "test");
DataRow myRow;
myRow = ds.Tables["test"].Rows[0];

MyData = (byte[])myRow["blobdata"];
int ArraySize;
ArraySize = MyData.GetUpperBound(0);

FileStream fs = new FileStream(@"C:\Data\image.rar", FileMode.OpenOrCreate, FileAccess.Write);
fs.Write(MyData, 0, ArraySize);
fs.Close();


Thanks!

King Regards!
countNazgul

modified on Thursday, July 3, 2008 10:42 AM

AnswerRe: C# Save data from DB (BLOB) Problem ... 1Kb is missing Pin
leppie3-Jul-08 4:34
leppie3-Jul-08 4:34 
GeneralRe: C# Save data from DB (BLOB) Problem ... 1Kb is missing Pin
countnazgul3-Jul-08 4:45
countnazgul3-Jul-08 4:45 
AnswerRe: C# Save data from DB (BLOB) Problem ... 1Kb is missing Pin
half-life3-Jul-08 6:21
half-life3-Jul-08 6:21 
GeneralRe: C# Save data from DB (BLOB) Problem ... 1Kb is missing Pin
countnazgul3-Jul-08 9:22
countnazgul3-Jul-08 9:22 
GeneralRe: C# Save data from DB (BLOB) Problem ... 1Kb is missing Pin
leppie3-Jul-08 22:46
leppie3-Jul-08 22:46 
QuestionPlease Help. Can anyone help me connect to a User-Autheticated ( Using AD ) Sharepoint site? Pin
AlexanderTheGreat073-Jul-08 4:09
AlexanderTheGreat073-Jul-08 4:09 
QuestionPrinting a windows form Pin
Nath3-Jul-08 3:28
Nath3-Jul-08 3:28 
AnswerRe: Printing a windows form Pin
Kristian Sixhøj3-Jul-08 3:44
Kristian Sixhøj3-Jul-08 3:44 
GeneralRe: Printing a windows form Pin
Nath4-Jul-08 20:28
Nath4-Jul-08 20:28 
Questionlost selection problem on mouse click in DataGridView Pin
Xmen Real 3-Jul-08 3:08
professional Xmen Real 3-Jul-08 3:08 
AnswerRe: lost selection problem on mouse click in DataGridView Pin
leppie3-Jul-08 3:56
leppie3-Jul-08 3:56 
GeneralRe: lost selection problem on mouse click in DataGridView Pin
Xmen Real 3-Jul-08 8:21
professional Xmen Real 3-Jul-08 8:21 
Questionfilesystemwatcher Pin
arkiboys3-Jul-08 2:37
arkiboys3-Jul-08 2:37 
AnswerRe: filesystemwatcher Pin
Xmen Real 3-Jul-08 2:56
professional Xmen Real 3-Jul-08 2:56 
QuestionI want to implement the Linked list, hash table functionality in .NET without using the standard inbuilt classes assuming they are not present.How Can I achieve this? Pin
sri_00993-Jul-08 2:34
sri_00993-Jul-08 2:34 
AnswerRe: I want to implement the Linked list, hash table functionality in .NET without using the standard inbuilt classes assuming they are not present.How Can I achieve this? PinPopular
leppie3-Jul-08 3:54
leppie3-Jul-08 3:54 
AnswerRe: I want to implement the Linked list, hash table functionality in .NET without using the standard inbuilt classes assuming they are not present.How Can I achieve this? Pin
leppie3-Jul-08 4:05
leppie3-Jul-08 4:05 

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.