Wednesday, March 28, 2012
how to save or retrieve a picture from a table in sql server 2000
am wondering how to save or retrieve an image in sql server 2000 table
using vb application or access thx
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!Hi
http://support.microsoft.com/defaul...kb;en-us;153238
http://support.microsoft.com/defaul...kb;en-us;194975
Regards
--
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Joe Saliba" <josephs73@.hotmail.com> wrote in message
news:OWE7fj3HFHA.3472@.TK2MSFTNGP09.phx.gbl...
> hi ,
> am wondering how to save or retrieve an image in sql server 2000 table
> using vb application or access thx
>
> *** Sent via Developersdex http://www.examnotes.net ***
> Don't just participate in USENET...get rewarded for it!|||You just "select " the colname from the table the same way you would any
other column data. On the client side, you need t otreat the output as a
byte array, and "eed" it to whatever it is being used in ... The techniques
for that part are dependant on what and how it is being used, and the
technology you are doing it in (VB6, VB/C#.Net, ASP, HTML, etc. etc. )
"Joe Saliba" wrote:
> hi ,
> am wondering how to save or retrieve an image in sql server 2000 table
> using vb application or access thx
>
> *** Sent via Developersdex http://www.examnotes.net ***
> Don't just participate in USENET...get rewarded for it!
>
Monday, March 26, 2012
How to save image to SQL Server 2000
I have to store images in database. I have a table which contains field picture which is an image.
How can I do this using C# ?
In Visual Studio .NET i found a code how to obtain BLOB values from the database but I do not know how to do upload an image to the database.
Thanks in advance for your help.
RafiIf you go to theData Access forum and search for BLOB you should be able to find the information you need.
Terri|||Thank you for information. I think I found there everything I needed
How to save image in sql server and display that image in datagrid?
Hay Friend's
Can u plese send me the way how to save image in sql server and display that images in datagrid or other control also like Image control or Image control Button?? Plese send the coding in C#.
Thank's
Amit
try this link...it display image in data grid...
http://www.odetocode.com/Articles/172.aspx
and for further reference you can refer
http://forums.asp.net/p/1122135/1754824.aspx#1754824
|||Hi amit, thanks for ur link but I m not fully Satisfy.. so kindly Send me more solutions..Thank'sAmit|||Hi Amit, Thanks for ur Link, but I m not fully Satisfy. So kindly send me more solutions ThanksAmit|||
Hi,
You can use stream object to insert the image to your database. Here's the sample for you to refer.
1.Store image in database:
Int64 intImageSize;string strImageType;Stream ImageStream;// Gets the Size of the ImageintImageSize = PersonImage.PostedFile.ContentLength;// Gets the Image TypestrImageType = PersonImage.PostedFile.ContentType;// Reads the ImageImageStream = PersonImage.PostedFile.InputStream;byte[] ImageContent =new byte[intImageSize + 1];int intStatus;intStatus = ImageStream.Read(ImageContent, 0, intImageSize);// Create Instance of Connection and Command ObjectSqlConnection myConnection =new SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"));SqlCommand myCommand =new SqlCommand("sp_person_isp", myConnection);// Mark the Command as a SPROCmyCommand.CommandType = CommandType.StoredProcedure;// Add Parameters to SPROCSqlParameter prmPersonImage =new SqlParameter("@.PersonImage", SqlDbType.Image);prmPersonImage.Value = ImageContent;myCommand.Parameters.Add(prmPersonImage);SqlParameter prmPersonImageType =new SqlParameter("@.PersonImageType", SqlDbType.VarChar, 255);prmPersonImageType.Value = strImageType;myCommand.Parameters.Add(prmPersonImageType);try {myConnection.Open();myCommand.ExecuteNonQuery();myConnection.Close();Response.Write("New person successfully added!");}catch (SqlException SQLexc) {Response.Write("Insert Failed. Error Details are: " + SQLexc.ToString());} 2. Retrieving Images from SqlServer and displaying in a DataGrid|||<asp:TemplateColumn HeaderText="Image"> <ItemTemplate> <asp:Image Width="150" Height="125" ImageUrl='<%# FormatURL(DataBinder.Eval(Container.DataItem, "PersonID"))%>' Runat=server /> </ItemTemplate></asp:TemplateColumn>//And the method FormatURL (A Server side Function) is as follows.public string FormatURL(object strArgument){return ("readrealimage.aspx?id=" + strArgument);}//And the method FormatURL (A Server side Function) is as follows.public string FormatURL(object strArgument){return ("readrealimage.aspx?id=" + strArgument);}///Database partpublic void Page_Load(object sender, EventArgs e){string strImageID = Request.QueryString("id");// Create Instance of Connection and Command ObjectSqlConnection myConnection =new SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"));SqlCommand myCommand =new SqlCommand("Select PersonImageType, PersonImage from das_person_real_images Where PersonID=" + strImageID, myConnection);// I have used the select statement. But it would be much much better, if you //could write a small stored procedure which contains the above sql statement.// Mark the Command as a SPROC (in case, if you wrote the stored procedure//myCommand.CommandType = CommandType.StoredProceduretry {myConnection.Open();SqlDataReader myDataReader;myDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);while ((myDataReader.Read())) {Response.ContentType = myDataReader.Item("PersonImageType");Response.BinaryWrite(myDataReader.Item("PersonImage"));}myConnection.Close();}catch (SqlException SQLexc) {}}Hope that helps. Thanks.
Hi, this is an interesting post. I am curious about if there is something similar you can do to display the SQL image field in a DataGrid in a Windows Forms application too?
Thanks in advance.
Jim
How to Save Image from VB 6 to Sql DB
I Want To Save My Picture From Vb 6 To Sql Data Base In Picture Field...plz Help Me What Code I Shlould Use..
Waiting Fro Ur Hopefull ReplayRefer these
http://www.aspfaq.com/show.asp?id=2149
http://www.microsoft.com/technet/prodtechnol/sql/2000/reskit/part3/c1161.mspx
Friday, February 24, 2012
HOW to Retrieve an image from sql server and display it in ASP.net using "imagemap or image
Ok, the problem is that , i have a field called "Attach" in sql of type image, when selecting it , the field is getting data of type BYTE(). which am being unable to display them on an Image on the panel.
using the following vb.net code:
'Dim sel2 As String
'Dim myCom As SqlCommand
'Dim conn As New SqlConnection
'Dim drr As SqlDataReader
'Dim image As System.Drawing.Image
'sel2 = "select * from attach where att_desc = '" & DropDownList1.SelectedItem().Text & "' and doc_code = " & w_doc_code & " and subcode = " & w_doc_subcode & " and doc_num= " & w_doc_num & " "
'conn.ConnectionString = ("server=developer01;uid=sa;password=aims;database=DVPSOC;timeout=45")
'myCom = New SqlCommand(sel2, conn)
'conn.Open()
'drr = myCom.ExecuteReader()
'If drr.Read Then
' Me.ImageMap1.ImageUrl = drr.Item("attach")
'End If
'conn.Close()
Am getting an exeption on the following line Me.ImageMap1.ImageUrl = drr.Item("attach")
saying: Conversion from type 'Byte()' to type 'String' is not valid.
knowing that i tried converting using ToString but it's not getting any output then.
thanks for your help.
a example in C# as below:
try
{
con = new SqlConnection(constr);
cmd = new SqlCommand("select photopath,Photo from employees where employeeid=14", con);
con.Open();
dr = cmd.ExecuteReader();
while(dr.Read())
{
if (!dr.IsDBNull(1))
{
byte[] photo = (byte[])dr[1];
MemoryStream ms = new MemoryStream(photo);
pictureBox1.Image = Image.FromStream(ms);
}
}
}
catch (Exception ex)
{
dr.Close();
cmd.Dispose();
con.Close();
MessageBox.Show(ex.Message);
}
hope can help u a little
|||Sorry but that is not the answer to the question. picturebox cannot be used in ASP.Net.
HOW to Retrieve an image from sql server and display it in ASP.net using "imagemap or image
Ok, the problem is that , i have a field called "Attach" in sql of type image, when selecting it , the field is getting data of type BYTE(). which am being unable to display them on an Image on the panel.
using the following vb.net code:
'Dim sel2 As String
'Dim myCom As SqlCommand
'Dim conn As New SqlConnection
'Dim drr As SqlDataReader
'Dim image As System.Drawing.Image
'sel2 = "select * from attach where att_desc = '" & DropDownList1.SelectedItem().Text & "' and doc_code = " & w_doc_code & " and subcode = " & w_doc_subcode & " and doc_num= " & w_doc_num & " "
'conn.ConnectionString = ("server=developer01;uid=sa;password=aims;database=DVPSOC;timeout=45")
'myCom = New SqlCommand(sel2, conn)
'conn.Open()
'drr = myCom.ExecuteReader()
'If drr.Read Then
' Me.ImageMap1.ImageUrl = drr.Item("attach")
'End If
'conn.Close()
Am getting an exeption on the following line Me.ImageMap1.ImageUrl = drr.Item("attach")
saying: Conversion from type 'Byte()' to type 'String' is not valid.
knowing that i tried converting using ToString but it's not getting any output then.
thanks for your help.
a example in C# as below:
try
{
con = new SqlConnection(constr);
cmd = new SqlCommand("select photopath,Photo from employees where employeeid=14", con);
con.Open();
dr = cmd.ExecuteReader();
while(dr.Read())
{
if (!dr.IsDBNull(1))
{
byte[] photo = (byte[])dr[1];
MemoryStream ms = new MemoryStream(photo);
pictureBox1.Image = Image.FromStream(ms);
}
}
}
catch (Exception ex)
{
dr.Close();
cmd.Dispose();
con.Close();
MessageBox.Show(ex.Message);
}
hope can help u a little
|||Sorry but that is not the answer to the question. picturebox cannot be used in ASP.Net.
HOW to Retrieve an image from sql server and display it in ASP.net using "imagemap or i
Ok, the problem is that , i have a field called "Attach" in sql of type image, when selecting it , the field is getting data of type BYTE(). which am being unable to display them on an Image on the panel.
using the following vb.net code:
'Dim sel2 As String
'Dim myCom As SqlCommand
'Dim conn As New SqlConnection
'Dim drr As SqlDataReader
'Dim image As System.Drawing.Image
'sel2 = "select * from attach where att_desc = '" & DropDownList1.SelectedItem().Text & "' and doc_code = " & w_doc_code & " and subcode = " & w_doc_subcode & " and doc_num= " & w_doc_num & " "
'conn.ConnectionString = ("server=developer01;uid=sa;password=aims;database=DVPSOC;timeout=45")
'myCom = New SqlCommand(sel2, conn)
'conn.Open()
'drr = myCom.ExecuteReader()
'If drr.Read Then
' Me.ImageMap1.ImageUrl = drr.Item("attach")
'End If
'conn.Close()
Am getting an exeption on the following line Me.ImageMap1.ImageUrl = drr.Item("attach")
saying: Conversion from type 'Byte()' to type 'String' is not valid.
knowing that i tried converting using ToString but it's not getting any output then.
thanks for your help.
a example in C# as below:
try
{
con = new SqlConnection(constr);
cmd = new SqlCommand("select photopath,Photo from employees where employeeid=14", con);
con.Open();
dr = cmd.ExecuteReader();
while(dr.Read())
{
if (!dr.IsDBNull(1))
{
byte[] photo = (byte[])dr[1];
MemoryStream ms = new MemoryStream(photo);
pictureBox1.Image = Image.FromStream(ms);
}
}
}
catch (Exception ex)
{
dr.Close();
cmd.Dispose();
con.Close();
MessageBox.Show(ex.Message);
}
hope can help u a little
|||Sorry but that is not the answer to the question. picturebox cannot be used in ASP.Net.