How to image insert and show user images by session?

Posted by Webmasters964 under ASP.NET on 9/20/2013 | Points: 10 | Views : 1323 | Status : [Member] | Replies : 6
I need the asp.net program to user login then display the user profile image for sessions pagelode ?




Responses

Posted by: Satyapriyanayak on: 9/20/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
http://www.c-sharpcorner.com/UploadFile/satyapriyanayak/display-username-along-with-photo-after-successful-login/

If this post helps you mark it as answer
Thanks

Webmasters964, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 9/20/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Refer this link
http://www.c-sharpcorner.com/UploadFile/satyapriyanayak/display-username-along-with-photo-after-successful-login/
http://www.aspdotnet-suresh.com/2012/04/aspnet-get-facebook-logged-in-user.html

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Webmasters964, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Webmasters964 on: 9/20/2013 [Member] Starter | Points: 25

Up
0
Down
without stored PROCEDURE image insert

Webmasters964, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 9/20/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Like the following code you should use all insert/update/delete button click events..... ( without using Stored Procedure)
private void btnclick_Click(object sender, EventArgs e)

{
// Creating instance of SqlConnection
SqlConnection conn = new SqlConnection("Database=student;Server=.;user=sa;password=aaaaaaa");
conn.Open();// open the database connection
SqlCommand cmd = new SqlCommand();// Creating instance of SqlCommand
cmd.Connection = conn; // set the connection to instance of SqlCommand
cmd.CommandText = "insert into student_detail values (" + txtrollno.Text + ",'" + txtname.Text + "','" + txtcourse.Text + "')"; // set
//the sql command ( Statement )
cmd.ExecuteNonQuery();
MessageBox.Show("Record Saved"); // showing messagebox for confirmation message for user
conn.Close();// Close the connection
}


Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Webmasters964, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 9/20/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
The following is for storing image into DB
protected void btnUpload_Click(object sender, EventArgs e)

{
//Condition to check if the file uploaded or not
if (fileuploadImage.HasFile)
{
//getting length of uploaded file
int length = fileuploadImage.PostedFile.ContentLength;
//create a byte array to store the binary image data
byte[] imgbyte = new byte[length];
//store the currently selected file in memeory
HttpPostedFile img = fileuploadImage.PostedFile;
//set the binary data
img.InputStream.Read(imgbyte, 0, length);
string imagename = txtImageName.Text;
//use the web.config to store the connection string
SqlConnection connection = new SqlConnection(strcon);
connection.Open();
SqlCommand cmd = new SqlCommand("INSERT INTO Image (ImageName,Image) VALUES (@imagename,@imagedata)", connection);
cmd.Parameters.Add("@imagename", SqlDbType.VarChar, 50).Value = imagename;
cmd.Parameters.Add("@imagedata", SqlDbType.Image).Value = imgbyte;
int count = cmd.ExecuteNonQuery();
connection.Close();
if (count == 1)
{
BindGridData();
txtImageName.Text = string.Empty;
ScriptManager.RegisterStartupScript(this, this.GetType(), "alertmessage", "javascript:alert('" + imagename + " image inserted successfully')", true);
}
}
}



Design should be:
<form id="form1" runat="server">

<div>
<table>
<tr>
<td>
Image Name:
</td>
<td>
<asp:TextBox ID="txtImageName" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Upload Image:
</td>
<td>
<asp:FileUpload ID="fileuploadImage" runat="server" />
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Button ID="btnUpload" runat="server" Text="Upload" onclick="btnUpload_Click" />
</td>
</tr>
</table>
</div>


For the above INSERT Table structure is as follows:
Column Name Data Type Allow Nulls
ImageId Int (set identity property=true) No
ImageName Varchar(50) Yes
Image image Yes


Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Webmasters964, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Raybrown on: 9/22/2013 [Member] Starter | Points: 25

Up
0
Down
You may refer to this guide for image displaying, from the basics of image display to more advanced features. It has introduced 30+ image and document formats displaying and viewing by loading image from files, graphics or downloading it from URL. Here is the link: http://www.rasteredge.com/how-to/vb-net-imaging/imaging-viewing/

Webmasters964, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response