Alter PROC SP_Excel (@ExcelName VARCHAR(100) ) As Begin Declare @SQL VARCHAR(1000) if OBJECT_ID('Table1') is not null drop table Table1 SET @SQL= 'select * INTO Table1 from openrowset (''Microsoft.ACE.OLEDB.12.0'',''Excel 12.0;Database=d:\Sharedd\'+@ExcelName+''',[Sheet1$])' EXEC(@SQL) ALter table Table1 add [UNO REEXECNAME] varchar(100),[UNO MOBILENO] varchar(20) update table1 set [UNO REEXECNAME]=b.FName+b.MName+b.LName ,[UNO MOBILENO]=b.MobileNo from LOln_LnDetails_h a join lgen_mktngagent b on a.LnRcvryExec=b.MktngAgentCode right join Table1 c on a.LnNo=c.[UNO LOAN NUMBER] select * from table1 End
protected void Button1_Click(object sender, EventArgs e) { connectionstring(); SqlConnection con = new SqlConnection(str); con.Open(); SqlCommand cmd = new SqlCommand("SP_Excel", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@ExcelName", SqlDbType.VarChar).Value = FileUpload1.FileName.ToString(); cmd.ExecuteNonQuery(); SqlDataAdapter da = new SqlDataAdapter(cmd); con.Close(); Button1.Visible = false; Button2.Visible = true; DataTable dt = new DataTable(); da.Fill(dt); GridView1.DataSource = dt; GridView1.DataBind(); ViewState["dtList"] = dt; Response.Write("<script>alert('Table Imported Successfully');</script>"); } protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView1.PageIndex = e.NewPageIndex; GridView1.DataBind(); }
I got it ..I changed AutogenerateColumn as True
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)