JQuery with ASP.NET: Save Copy / Paste Excel Data to a Database Table

Justin Cooney

Have you ever wanted to help your users move data from Excel to your Web application? In this article I will give an example in ASP.NET that takes copied Excel spreadsheet rows from the user’s clipboard and saves the information to a SQL Server database table.

Since ASP.NET runs at the server level, you will need to use JavaScript/JQuery to get the Excel information from the user’s clipboard. You will need to use a different command to get the information depending on the user’s browser. In this example, I code specifically for Internet Explorer, but this is just since I am giving an example. In a real-world application you would code for all of the major browsers.

View original post 839 more words

How to Pass Sql Parameters in SqlServer througn asp.net

Sometimes we need to execute storedprocedures in our asp.net

if we want to pass any parameters the following things will help..


SqlConnection con =

new SqlConnection("Data Source=SERVER2;Initial Catalog=IC;User ID=sa;Password=123");

SqlCommand cmd = new SqlCommand("sp_Register",con);

cmd.Parameters.AddWithValue("@fname", TextBox1.Text);

cmd.Parameters.AddWithValue("@lname", TextBox2.Text);

cmd.Parameters.AddWithValue("@address", TextBox3.Text);

cmd.Parameters.AddWithValue("@uname", TextBox4.Text);

cmd.Parameters.AddWithValue("@pwd", TextBox5.Text);

cmd.Parameters.AddWithValue("@mail", TextBox6.Text);

SqlDataAdapter da = new SqlDataAdapter(cmd);

DataSet ds = new DataSet();



SqlParameter[] p = new SqlParameter[9];

p[0] = new SqlParameter("@username", TextBox1.Text);

p[1] = new SqlParameter("@firstname", TextBox2.Text);

p[2] = new SqlParameter("@lastName", TextBox3.Text);

p[3] = new SqlParameter("@state", TextBox4.Text);

p[4] = new SqlParameter("@city", TextBox5.Text);

p[5] = new SqlParameter("@location", TextBox6.Text);

p[6] = new SqlParameter("@mobile", TextBox7.Text);

p[7] = new SqlParameter("@zipcode", TextBox8.Text);

p[8] = new SqlParameter("@emailid", TextBox9.Text);


string _sql = "Sp_UserRegistration";

SqlParameter[] Param = new SqlParameter[6];

Param[0] = new SqlParameter("@fname", SqlDbType.VarChar, 200);

Param[0].Value = TextBox1.Text;

Param[1] = new SqlParameter("@lname", SqlDbType.VarChar, 200);

Param[1].Value = TextBox2.Text;

Param[2] = new SqlParameter("@address", SqlDbType.NVarChar);

Param[2].Value = TextBox3.Text;

Param[3] = new SqlParameter("@uname", SqlDbType.NVarChar);

Param[3].Value = TextBox4.Text;

Param[4] = new SqlParameter("@pwd", SqlDbType.NVarChar);

Param[4].Value = TextBox5.Text;

Param[5] = new SqlParameter("@mail", SqlDbType.VarChar, 100);

Param[5].Value = TextBox6.Text;