How To Establish A Connection To Database Using C# Application?
Im using Visual Studio 2008 . and wants to connect to database. My Application (in C#) is to develop a form acts like Image Viewer and to perform insert an image and delete an image , Also To Display the images I开发者_如何转开发n Database
Refer this walkthrough:
http://msdn.microsoft.com/en-us/library/tzedkwye%28v=VS.80%29.aspx
Assuming that your DBMS
is Sql server
. You could do for example
SqlConnection conn = new SqlConnection("connString here");//conn string here
conn.Open();//if using SqlDataReader
SqlCommand cmd = new SqlCommand("your query", conn);///your command object
....
.....
In order to insert the image to the database, there are mainly two options, either to save the image path
in the database or save the image itself in database as BLOB
.
精彩评论