{
string filePath = FileUpLoad1.PostedFile.FileName;
string filenameStor = FileUpLoad1.FileName;
string filenameType = Path.GetExtension(FileUpLoad1.PostedFile.FileName);
if (filenameType.ToString().Trim().ToLower() == ".csv")
{
FileUpLoad1.SaveAs(@"c:\\sites\\" + "Book1.csv");
lblStatus.Text = "File Uploaded : " + FileUpLoad1.PostedFile.FileName;
insFileName();
SqlDataSource1.SelectCommand = "SELECT * FROM vdcsvfl";
gvid.Visible = true;
Button1.Visible = true;
}
else
{
lblStatus.Text =
"Invalid File Type...";}
}
else{
lblStatus.Text =
"No File Uploaded.";gvid.Visible =
true;Button1.Visible =
true;}
}
void insFileName(){
SqlConnection myConnection = new SqlConnection(ConnectionString); string strSQL;strSQL =
"insbulkcsvP"; SqlCommand cmd = new SqlCommand(strSQL, myConnection);cmd.CommandType =
CommandType.StoredProcedure;myConnection.Open();
cmd.ExecuteNonQuery();
myConnection.Close();
lblStatus.Text =
"Added..";ALTER
proc [dbo].[insbulkcsvP] asdelete
from dbo.vdcsvflAlter
Table vdcsvfl Drop Column id--ALTER TABLE a DROP COLUMN y
BULK
INSERT dbo.vdcsvflFROM
'c:\sites\Book1.csv'WITH
(
FIELDTERMINATOR
= ',',ROWTERMINATOR
= '\n')
delete
from dbo.vdcsvfl where video_id='video_id'Alter
Table vdcsvfl Add id int identity(1,1) --primary key
No comments:
Post a Comment