Click here to Skip to main content
15,894,291 members
Home / Discussions / C#
   

C#

 
AnswerRe: How can I catch the Mouse Click? Pin
Not Active21-Nov-07 8:51
mentorNot Active21-Nov-07 8:51 
GeneralRe: How can I catch the Mouse Click? Pin
Khoramdin21-Nov-07 8:56
Khoramdin21-Nov-07 8:56 
GeneralRe: How can I catch the Mouse Click? Pin
Not Active21-Nov-07 10:08
mentorNot Active21-Nov-07 10:08 
GeneralRe: How can I catch the Mouse Click? Pin
Khoramdin21-Nov-07 12:21
Khoramdin21-Nov-07 12:21 
Questionhow I can insert image into sqlserver database with c# Pin
yemen_programmer21-Nov-07 7:04
yemen_programmer21-Nov-07 7:04 
Questionhow I can insert image into sqlserver database with c# Pin
yemen_programmer21-Nov-07 6:54
yemen_programmer21-Nov-07 6:54 
AnswerRe: how I can insert image into sqlserver database with c# Pin
Giorgi Dalakishvili21-Nov-07 7:03
mentorGiorgi Dalakishvili21-Nov-07 7:03 
AnswerRe: how I can insert image into sqlserver database with c# [modified] Pin
Khoramdin21-Nov-07 8:44
Khoramdin21-Nov-07 8:44 
Hello yemen_programmer,

As far as I know, there are TWO ways to do so.

1- To store only the location of the image into your database and the image file in a different folder.

2- To store the image file as a BLOB file.

The option 1 is stright forward as you only store a text into your database while your image sits in a folder. Therefore, I am going to leave that.

The second option can be done with a code similar to the one here. Keep in mind that this line of code uses MySQL database and the command line "INSERT INTO ....." may be different for SQL and you need to check that out. I personaly use MySQL. The following code also includes storing other information about the stored image. But the most important one that you require is ItemImage and ImgeSize.

                    OdbcCom = new System.Data.Odbc.OdbcCommand("INSERT INTO item VALUES (NULL, ?, ?, ?, ?);", OdbcCon);<br />
<br />
                    OdbcCom.Parameters.Add("@ItemName", System.Data.Odbc.OdbcType.VarChar);<br />
                    OdbcCom.Parameters["@ItemName"].Value = txtItemName.Text;<br />
<br />
                    OdbcCom.Parameters.Add("@ItemImage", System.Data.Odbc.OdbcType.Image);<br />
                    OdbcCom.Parameters["@ItemImage"].Value = ImageArray;<br />
<br />
                    OdbcCom.Parameters.Add("@ImageSize", System.Data.Odbc.OdbcType.Int);<br />
                    OdbcCom.Parameters["@ImageSize"].Value = FileSize;<br />
<br />
                    OdbcCom.Parameters.Add("@ItemInfo", System.Data.Odbc.OdbcType.VarChar);<br />
                    OdbcCom.Parameters["@ItemInfo"].Value = txtItemInfo.Text;<br />
<br />
                    OdbcCom.ExecuteNonQuery();


Keep in mind that before being able to do so, you need to place your image in an Array which in the above code is called ImageArray.

I hope that could help you out to get your image into your database.

Cheers,

Khoramdin


-- modified at 14:49 Wednesday 21st November, 2007
QuestionCreate Shortcut in C# for Vista Pin
Phoen2521-Nov-07 6:30
Phoen2521-Nov-07 6:30 
AnswerRe: How to Open Url Pin
Anthony Mushrow21-Nov-07 6:04
professionalAnthony Mushrow21-Nov-07 6:04 
Question[Message Deleted] Pin
Shani Aulakh21-Nov-07 5:43
Shani Aulakh21-Nov-07 5:43 
AnswerRe: C#: Method help Pin
Judah Gabriel Himango21-Nov-07 5:59
sponsorJudah Gabriel Himango21-Nov-07 5:59 
AnswerRe: C#: Method help Pin
Anthony Mushrow21-Nov-07 6:08
professionalAnthony Mushrow21-Nov-07 6:08 
AnswerRe: C#: Method help Pin
J4amieC21-Nov-07 6:36
J4amieC21-Nov-07 6:36 
GeneralRe: C#: Method help Pin
Anthony Mushrow21-Nov-07 7:53
professionalAnthony Mushrow21-Nov-07 7:53 
QuestionI need a Sample code! Pin
Davood Riazi21-Nov-07 5:00
Davood Riazi21-Nov-07 5:00 
AnswerRe: I need a Sample code! Pin
Colin Angus Mackay21-Nov-07 5:32
Colin Angus Mackay21-Nov-07 5:32 
GeneralRe: I need a Sample code! Pin
Davood Riazi25-Nov-07 3:40
Davood Riazi25-Nov-07 3:40 
QuestionHow to count pixels Pin
A.Asif21-Nov-07 4:35
A.Asif21-Nov-07 4:35 
AnswerRe: How to count pixels Pin
V.21-Nov-07 4:47
professionalV.21-Nov-07 4:47 
AnswerRe: How to count pixels Pin
Skippums21-Nov-07 6:06
Skippums21-Nov-07 6:06 
QuestionHow to know if a thread is waiting for an event ?! Pin
Karma Komae21-Nov-07 4:14
Karma Komae21-Nov-07 4:14 
AnswerRe: How to know if a thread is waiting for an event ?! Pin
Luc Pattyn21-Nov-07 4:35
sitebuilderLuc Pattyn21-Nov-07 4:35 
GeneralRe: How to know if a thread is waiting for an event ?! Pin
Karma Komae21-Nov-07 4:52
Karma Komae21-Nov-07 4:52 
GeneralRe: How to know if a thread is waiting for an event ?! Pin
Luc Pattyn21-Nov-07 9:45
sitebuilderLuc Pattyn21-Nov-07 9:45 

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.