C# SQL insert command

First of all: STOP concatenating together your SQL code!! This is an invitation to hackers everywhere to attack you with SQL injection! Use parametrized queries instead! I would use this solution: create a single SqlCommand with a parametrized query, and execute that: string stmt = “INSERT INTO dbo.Test(id, name) VALUES(@ID, @Name)”; SqlCommand cmd = new … Read more

Web SQL Database + Javascript loop

Do it the other way around: <script> numberofArticles = 5; db = openDatabase(“websql”, “0.1”, “web-sql testing”, 10000); db.transaction(function(tx) { tx.executeSql(‘CREATE TABLE IF NOT EXISTS LOGS (id unique, articleID int)’); }); db.transaction(function (tx) { for (var i=0; i<=numberofArticles-1; i++){ tx.executeSql(‘INSERT INTO LOGS (articleID) VALUES (?)’, [i]); }; }); </script> And the alternative, the proper way with … Read more

C# Count Vowels

Right now, you’re checking whether the sentence as a whole contains any vowels, once for each character. You need to instead check the individual characters. for (int i = 0; i < sentence.Length; i++) { if (sentence[i] == ‘a’ || sentence[i] == ‘e’ || sentence[i] == ‘i’ || sentence[i] == ‘o’ || sentence[i] == ‘u’) … Read more