Click here to Skip to main content
14,765,861 members
Home » Discussions » C#
   

C#

 
AnswerRe: C# working with Sapces in registry Keys Pin
User 66583-Jul-08 5:55
MemberUser 66583-Jul-08 5:55 
GeneralRe: C# working with Sapces in registry Keys Pin
Planker3-Jul-08 8:31
MemberPlanker3-Jul-08 8:31 
QuestionHow to disbale outlook security warnings while sending mails Pin
sivasankar anumula3-Jul-08 5:45
Membersivasankar anumula3-Jul-08 5:45 
AnswerRe: How to disbale outlook security warnings while sending mails Pin
MumbleB3-Jul-08 7:50
MemberMumbleB3-Jul-08 7:50 
QuestionWebclient.DownloadFilesAsync issue Pin
Reason Man3-Jul-08 5:17
MemberReason Man3-Jul-08 5:17 
AnswerRe: Webclient.DownloadFilesAsync issue Pin
Michael90003-Jul-08 9:03
MemberMichael90003-Jul-08 9:03 
AnswerRe: Webclient.DownloadFilesAsync issue Pin
Anthony Mushrow3-Jul-08 9:34
professionalAnthony Mushrow3-Jul-08 9:34 
QuestionC# Save data from DB (BLOB) Problem ... 1Kb is missing [modified] Pin
countnazgul3-Jul-08 5:13
Membercountnazgul3-Jul-08 5: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 5:34
Memberleppie3-Jul-08 5:34 
GeneralRe: C# Save data from DB (BLOB) Problem ... 1Kb is missing Pin
countnazgul3-Jul-08 5:45
Membercountnazgul3-Jul-08 5:45 
AnswerRe: C# Save data from DB (BLOB) Problem ... 1Kb is missing Pin
half-life3-Jul-08 7:21
Memberhalf-life3-Jul-08 7:21 
GeneralRe: C# Save data from DB (BLOB) Problem ... 1Kb is missing Pin
countnazgul3-Jul-08 10:22
Membercountnazgul3-Jul-08 10:22 
GeneralRe: C# Save data from DB (BLOB) Problem ... 1Kb is missing Pin
leppie3-Jul-08 23:46
Memberleppie3-Jul-08 23:46 
QuestionPlease Help. Can anyone help me connect to a User-Autheticated ( Using AD ) Sharepoint site? Pin
AlexanderTheGreat073-Jul-08 5:09
MemberAlexanderTheGreat073-Jul-08 5:09 
QuestionPrinting a windows form Pin
Nath3-Jul-08 4:28
MemberNath3-Jul-08 4:28 
AnswerRe: Printing a windows form Pin
Kristian Sixhøj3-Jul-08 4:44
MemberKristian Sixhøj3-Jul-08 4:44 
GeneralRe: Printing a windows form Pin
Nath4-Jul-08 21:28
MemberNath4-Jul-08 21:28 
Questionlost selection problem on mouse click in DataGridView Pin
Xmen Real 3-Jul-08 4:08
professional Xmen Real 3-Jul-08 4:08 
AnswerRe: lost selection problem on mouse click in DataGridView Pin
leppie3-Jul-08 4:56
Memberleppie3-Jul-08 4:56 
GeneralRe: lost selection problem on mouse click in DataGridView Pin
Xmen Real 3-Jul-08 9:21
professional Xmen Real 3-Jul-08 9:21 
Questionfilesystemwatcher Pin
arkiboys3-Jul-08 3:37
Memberarkiboys3-Jul-08 3:37 
AnswerRe: filesystemwatcher Pin
Xmen Real 3-Jul-08 3:56
professional Xmen Real 3-Jul-08 3: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 3:34
Membersri_00993-Jul-08 3: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? Pin
leppie3-Jul-08 4:54
Memberleppie3-Jul-08 4: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 5:05
Memberleppie3-Jul-08 5: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.