Posts

Showing posts from 2024

Host Angular app INSIDE C# Web Api 2 (as single app) (not .Net Core) and install in server (and browse from outside)

Image
Host Angular inside ANY C# / ASP.NET solution. Table of Content: Web Dev Tools List Create DB (ms-sql) Create API (c# webapi 2) + connect to DB Create Angular project  + connect to API Host the NgApp inside the API Install in Server + connect from internet 1. Web Dev Tools List The list of tools : they are all "Next,  Next, Next...", and they are all on google search, SSMS - Sql Server Management Tool - for SQL (also installs server) VS22 - Visual Studio 2022 Community - dont forget to check Asp.Net dev tools with .Net framewroks 4.6.1-4.8 VSC - Visual Studio Code NodeJS (version compatible to the angular version) Angular (your version) For server install - windows server (2022) with IIS 2. Create DB Open SSMS (type "SQL" in start) There, copy your server name (before click "Connect"): Create a DB and a Table (just right-click -> "New..." and give names) Make sure you have an "Id" columns that is key identity, by double-clicking the

3 Simple ways to retrieve generic SQL data with C# / WebAPI controller (using DataRow)

Image
Full Code in the end! :) Assuming you have some connection string: private static string ConnectionString = ConfigurationManager.AppSettings["myConnStrApp"]; And assuming we are using the simple "SqlDataAdapter", our Method will start with: using (SqlConnection conn = new SqlConnection(ConnectionString)) {       using (SqlDataAdapter adp = new SqlDataAdapter("SELECT * FROM " + tblname, conn)) {             DataSet ds = new DataSet("ds");             adp.Fill(ds); We have 2 generic options return (convert to) Json String build json object Lets 1st mention the "standard" way - by class model. That means we need to create a new C# class per sql table, and then create matching parsing mechanism, meaning that the rest of our method contains this (see more in the end): var rows = ds.Tables[0].Rows; for (int i = 0; i < rows.Count; i++) {     var r = rows[i];     t.Add(new TNG() {         Id = int.Parse(r["Id"].ToString()),        

PowerApps Patch new SharePoint list item with conditional / dynamically adding fields

Important   if you get an error that says: powerapps patch sharepoint list error the specified column "" does not exist the column with the most similar name is "" that would be because you use the column DisplayName instead of the InternalName Solution:  Set(oItem, {     Title:me.displayName,     EmpITref:{Id:meSP.ID, Value:meSP.Title},     EducationLevel:EducationLevel.SelectedText.Value,     CertCount:vis,     WorkYearsExp:WorkYearsExp.SelectedText.Value,     anythingElse:anythingElse.Text,     DigitalSignature:DigSign.Text }); If(vis<>0, Set( oItem, Patch (oItem, {     Cert1_x002d_OrgAd:cert1_orgAd.Text,      Cert1_x002d_Title: cert1_title.Text,     Cert1_x002d__x0023_:cert1_No.Text,      Cert1_x002d_GrantDate:cert1_grant.SelectedDate,     Cert1_x002d_exp_x002e_Date:cert1_exp.SelectedDate }))); If(vis=2, Set( oItem, Patch (oItem, {     Cert2_x002d_OrgAd:cert2_orgAd.Text,      Cert2_x002d_Title: cert2_title.Text,     Cert2_x002d__x0023_:cert2_No.Text,