✅ Error: The remote server returned an error: (403)
i try to download files from sharepoint and after that it gives me an exeption
i know the string are empty but just privat
my code:
i know the string are empty but just privat
my code:
using System;
using System.Data;
public class Program
{
public static void Main(string[] args)
{
try
{
string filename = "";
string sharepointUrl = "";
string sheetName = "";
string connectionString = "";
string tableName = "";
string username = "";
string password = "";
Console.WriteLine("Lade Datei von SharePoint herunter");
SharePointDownloader.DownloadFile(sharepointUrl, filename, username, password);
Console.WriteLine("Lese Excel-Datei herunter");
DataTable dataTable = ExcelReader.ReadExcelFile(filename, sheetName);
dataTable.Columns.Add("Dateiname", typeof(string));
foreach (DataRow row in dataTable.Rows)
{
row["Dateiname"] = filename;
}
Console.WriteLine("Importiere Daten in die SQL-Datenbank");
SqlImporter.ImportToSqlDatabase(dataTable, connectionString, tableName);
Console.WriteLine("Führe gespeicherte Prozedur aus");
SqlImporter.ExecuteStoredProcedure(connectionString, "sp_async_SP_starter_Trigger", "Import VKS Strom", "ABRECHNUNG", "sp_zev_upsertNBK", filename);
Console.WriteLine("Daten erfolgreich in die SQL-Datenbank importiert");
}
catch (Exception ex)
{
Console.WriteLine("Fehler: " + ex.Message);
}
finally
{
Console.WriteLine("Drücken Sie eine beliebige Taste, um das Programm zu beenden");
Console.ReadKey();
}
}
}using System;
using System.Data;
public class Program
{
public static void Main(string[] args)
{
try
{
string filename = "";
string sharepointUrl = "";
string sheetName = "";
string connectionString = "";
string tableName = "";
string username = "";
string password = "";
Console.WriteLine("Lade Datei von SharePoint herunter");
SharePointDownloader.DownloadFile(sharepointUrl, filename, username, password);
Console.WriteLine("Lese Excel-Datei herunter");
DataTable dataTable = ExcelReader.ReadExcelFile(filename, sheetName);
dataTable.Columns.Add("Dateiname", typeof(string));
foreach (DataRow row in dataTable.Rows)
{
row["Dateiname"] = filename;
}
Console.WriteLine("Importiere Daten in die SQL-Datenbank");
SqlImporter.ImportToSqlDatabase(dataTable, connectionString, tableName);
Console.WriteLine("Führe gespeicherte Prozedur aus");
SqlImporter.ExecuteStoredProcedure(connectionString, "sp_async_SP_starter_Trigger", "Import VKS Strom", "ABRECHNUNG", "sp_zev_upsertNBK", filename);
Console.WriteLine("Daten erfolgreich in die SQL-Datenbank importiert");
}
catch (Exception ex)
{
Console.WriteLine("Fehler: " + ex.Message);
}
finally
{
Console.WriteLine("Drücken Sie eine beliebige Taste, um das Programm zu beenden");
Console.ReadKey();
}
}
}