Ako zadadat do spustenie ulozenej procedury v kode tlacitka.
protected void btnSend_Click(object sender, EventArgs e)
{
// tu chcem spustit ulozenu proceduru "vycisti_tabulku"
//cesta k nahrávanému súboru
//string path = fileuploadExcel.PostedFile.FileName;
string path = "w:\\Domains\\Intranet.hazz-zi.sk\\webaplik\\EvidOdbornosti2\\Import\\Odbornosti.xlsx";
//Vytvorenie connection string na Excelovský work book
string excelConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;Persist Security Info=False";
//Vytvorenie spojenia na Excelovský work book
OleDbConnection excelConnection = new OleDbConnection(excelConnectionString);
//Vytvorenie OleDbCommand-u na načítanie dát z Excelu
OleDbCommand cmd = new OleDbCommand("Select [PrislusniciId],[OsCislo],[Meno],[OrgJednotkaH],[OrgJednotkaD],[Profesia],[status],[NaklStr],[Zmenil],[ZmenDna],[Zaciatok],[Koniec],[Novy] from [Ludia$]", excelConnection);
excelConnection.Open();
OleDbDataReader dReader;
dReader = cmd.ExecuteReader();
SqlBulkCopy sqlBulk = new SqlBulkCopy(strConnection);
//sem treba zadat názov cielovej tabulky v databáze Peronal2 na SQL servri
sqlBulk.DestinationTableName = "PrislusniciImport";
sqlBulk.WriteToServer(dReader);
excelConnection.Close();
// tu chcem spustit ulozenu proceduru "spracuj_import"
}
Vlastne je to kod na import tabulky z xlsx do MSSQL tabulky len potrebujem spustit pred tým ulozenu proceduru "vycisti_tabulku" a po importe dat z excelu este jednu ulozenu proceduru "spracuj_import" Dik
|