Click here to Skip to main content
15,894,254 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C# code
C#
protected void Button1_Click1(object sender, EventArgs e)
    {
        string filename = Path.GetFileName(FileUpload1.PostedFile.FileName);
        string pathName = "userimage/" + filename;
        FileUpload1.SaveAs(Server.MapPath("userimage/" + filename));
        if (FileUpload1.HasFile)
        {
            con = new SqlConnection(strcon);
            cmd = new SqlCommand("ram", con);
            cmd.CommandType = CommandType.StoredProcedure;
            con.Open();
            cmd.Parameters.AddWithValue("@Action", "INSERT");
            cmd.Parameters.AddWithValue("@name", TextBox2.Text);
            cmd.Parameters.AddWithValue("@pass", TextBox3.Text);
            cmd.Parameters.AddWithValue("@mails", TextBox4.Text);
            cmd.Parameters.AddWithValue("@upload", filename);
            cmd.Parameters.AddWithValue("@paths", pathName);
            cmd.Parameters.AddWithValue("@update", DateTime.Now);      
            cmd.ExecuteNonQuery();
            con.Close();
            FillGrid();
            lblMessage.Text = "registered sucess";
            Response.Redirect("~/register.aspx");
            ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "alert('Registered successfully..!! ');", true);
        }
        else
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "alert('Please select a file to upload ');", true);
        }
    }

stored procedure
SQL
USE [prakash]
GO
/****** Object:  StoredProcedure [dbo].[ram]    Script Date: 11/27/2014 10:56:03 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[ram]
   (
    @eid int=0,
	@name varchar(50)='', 
	@pass varchar(50)='', 
    @mails nvarchar(50)='', 
	@paths nvarchar(50)='', 
	@upload varchar(MAX)='', 
	@update datetime='', 
    @Action as varchar(50)='' 

)
AS
BEGIN	
	SET NOCOUNT ON;
	if(@Action='display')
begin
	SELECT *FROM getezee
	END
--INSERT
    else if(@Action = 'INSERT')
      BEGIN
            INSERT INTO getezee(username,password,mail,imagename,uploadimage,updatedby)
            VALUES (@name, @pass,@mails,@paths,@upload,@update)
      END

--UPDATE
    else IF(@Action = 'UPDATE')
      BEGIN
            UPDATE getezee
            SET username = @name, password = @pass
            WHERE id = @eid
      END
 --DELETE
    else IF(@Action = 'DELETE')
      BEGIN
            DELETE getezee
            WHERE id = @eid
      END
	  END
Posted
Updated 26-Nov-14 18:46pm
v2
Comments
Member 10918596 27-Nov-14 0:32am    
here image uploading not working
/\jmot 27-Nov-14 0:53am    
what is the error?>?

Debug the code, and see where the problem arise and search it on Google, still can't find or can't understand then post here the problem..
 
Share this answer
 
v2
Comments
Thanks7872 27-Nov-14 1:29am    
You are asking for clarification and just after that posting solution,Why? OP has problem with the code which he has already mentioned,than why link to some another way?
/\jmot 27-Nov-14 1:38am    
is he post about the problem??
where he gets the error?

where?? i can't see it.
will you show me??
/\jmot 27-Nov-14 1:39am    
yes, my link was wrong..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900