Accessing variables from other namespaces

Leave a Comment
Normally, variables don't live in a namespace alone, they live inside another class that could be in another namespace. If you need to access a variable in another class (in another namespace), your other class needs to expose the variable somehow. The common practice for this is to use a public Property (static if you only need access to that variable) for the variable. namespace My.Namespace { public class MyClassA { public void MyMethod() { // Use value from MyOtherClass ...

MySQL: Reorder/Reset auto increment primary key?

Leave a Comment
To reset the IDs of my User table, I use the following SQL query. It's been said above that this will ruin any relationships you may have with any other tables. ALTER TABLE `users` DROP `id`; ALTER TABLE `users` AUTO_INCREMENT = 1; ALTER TABLE `users` ADD `id` int UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST...

Execute c# code automatically every 1 minute

Leave a Comment
How I can do that consol aplication do some function every one minute? This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters ...

AJAX ADD & RETRIEVE MYSQL RECORDS USING JQUERY & PHP

Leave a Comment
I love jQuery framework, feels like we can do some awesome things easily. If you are familiar with the basic of jQuery framework too, the next thing you have to do is learn to use jQuery Ajax to add and retrieve records from MySql database. Let’s take a look at how we implement real time add and retrieve records using Ajax. Database sample database comment table columns id, name and message ...

C# and MySql : Retrieve Data using MySqlDataReader

Leave a Comment
C# and MySql : Retrieve Data using MySqlDataReader String str = @"server=localhost;database=yourDBname;userid=root;password=yourDBpassword;"; MySqlConnection con = null; //MySqlDataReader Object MySqlDataReader reader = null; try { con = new MySqlConnection(str); con.Open(); //open the connection //We will need to SELECT all or some columns in the table //via this command String cmdText = "SELECT * FROM myTable"; MySqlCommand...

C# and MySql : SELECT , UPDATE , DELETE

Leave a Comment
To Execute Some MySql Statements: SELECT: //This is the simple code of executing MySql Commands in C# String cmdText = "SELECT id,name,contact FROM myTable"; //This line is the MySql Command MySqlCommand cmd = new MySqlCommand(cmdText, con); cmd.ExecuteNonQuery(); //Execute the command UPDATE: //example on how to use UPDATE cmd = new MySqlCommand("UPDATE ab_data SET banned_from='" + from + "' , banned_until='"...

C# : To Connect to a MySql Database

Leave a Comment
Things Needed: You should have installed MySQL and MySQL Connector/NET. You can download installers from http://dev.mysql.com/downloads Microsoft Visual C# or Visual Studio. Download and install MySql for Windows. DownloadHere To use the methods in the MySQL Connector/NET you should add a reference to it. Right click your project in the Solution Explorer and click Add Reference… In the .NET tab, chose MySql.Data and click ok. ...