Click here to Skip to main content
15,915,019 members
Home / Discussions / C#
   

C#

 
AnswerRe: confirmed file creation Pin
Michael90003-Jul-08 7:41
Michael90003-Jul-08 7:41 
QuestionAuto updateing applcation. Pin
Simon P Stevens3-Jul-08 5:16
Simon P Stevens3-Jul-08 5:16 
AnswerRe: Auto updateing applcation. Pin
half-life3-Jul-08 6:12
half-life3-Jul-08 6:12 
GeneralRe: Auto updateing applcation. Pin
Simon P Stevens3-Jul-08 21:39
Simon P Stevens3-Jul-08 21:39 
AnswerRe: Auto updateing applcation. Pin
led mike3-Jul-08 6:35
led mike3-Jul-08 6:35 
GeneralRe: Auto updateing applcation. Pin
Simon P Stevens3-Jul-08 22:10
Simon P Stevens3-Jul-08 22:10 
GeneralRe: Auto updateing applcation. Pin
led mike7-Jul-08 10:58
led mike7-Jul-08 10:58 
QuestionChanging columns during update when using virtual listview Pin
Hampus@foi3-Jul-08 4:55
Hampus@foi3-Jul-08 4:55 
QuestionC# working with Sapces in registry Keys Pin
Planker3-Jul-08 4:47
Planker3-Jul-08 4:47 
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 

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.