Jump to content

Check out our Community Blogs


Member Since 01 Aug 2012
Offline Last Active Sep 17 2012 04:13 PM

#635894 Insert string from C# program

Posted by ertan on 13 August 2012 - 07:26 AM

Hi :)

calm down ...

in sql, string needs ' (single quote) means you need to write your strings between two quates in your sql query.

let me give you an example

string word = "Hello";


, "INSERT into Table1 values ('" + word + "')"

it must work.


... ( ' " + word + " ' ) "
  • 1

#635849 Embedded Systems

Posted by ertan on 12 August 2012 - 06:09 PM


I am also interested in MCU programming. But I don't understand how can you program MCU with C#? I usually use CCS C or Pic basic to program MCUs. Your C codes already will be hex code and will burn it to MCU via MCU programmer.

To control MCU, you can use USB or serial or parallel ports. I prefer to communicate with MCU via USB. There are some kind of libraries which support USB communication with C# (i.e. umng.dll)

You can look at my presantation about my thesis. http://prezi.com/ozd...lektroid-sunum/

but its in Turkish.. I developed a server program (c#), a client (android) and an electronic device ( programmed by CCS C). MCU was PIC 18F4550 which supports USB ( also I could use PIC 18f2550 is cheaper but no more output)

If you have any question, dont hesitate to ask me.

good luck,

  • 1

#635848 [SQL Query]Stop program from being laggy while excuting?

Posted by ertan on 12 August 2012 - 05:55 PM

As-Salāmu `Alaykum,

I generally use like that

SqlConnection sqlConnection = this.sqlcon();
SqlCommand sqlCommand = new SqlCommand();
sqlCommand.Connection = sqlConnection;
//the part where the big dbo loads..
sqlCommand.CommandText = "USE " + mainclass.database + " SELECT IT.id, ST.value FROM ItemResource IT, StringResource ST WHERE IT.name_id = ST.code ORDER BY id ASC";
SqlDataAdapter da = new SqlDataAdapter(sqlCommand);
DataSet ds = new DataSet();
this.dataGridView1.DataSource = ds.Tables[0];
catch (Exception ex)
MessageBox.Show(ex.Message.ToString(), "Error!");

just try it and see how its performance.. If its similar like before one then as Jorndel said, you can try backgroundwork or thread or Parallel.For/Foreach for your while loop.

have a good ramadan

good luck :)
  • 1

#635393 Accessing public variables through library's?

Posted by ertan on 06 August 2012 - 05:43 PM

Var1 must be a static field. dont think so much about field :) its a kind of variable..

public static int Var1; is a field..
int X; is also a field..

as I see your code, var1 must be static variable..
  • 1

#634965 Generation / Combination Of Text From Inputs?

Posted by ertan on 01 August 2012 - 06:55 PM

This is more compex and useful sample. I hope its okay for you :)

		 List<string> names = new List<string>();
		 List<string> ages = new List<string>();
		 List<string> hobbies= new List<string>();

		 Random r = new Random();
		 for (int i = 0; i < 10; i++)
			 int index = r.Next(0, names.Count); // it generates random numer. the max number depends on names list's count

			 MessageBox.Show(String.Format("Hello my name is {0} and I am {1} years old. I enjoy to {2} in my free time.", names[index], ages[index], hobbies[index]));

I used list. I forgot tht firstly you must add

using System.Collections.Generic;

after you can use list.

if you dont understand any think, please dont hesitate to ask me :)

good luck
  • 1

#634961 Display Msg When Either One Of The Checkbox Not Checked

Posted by ertan on 01 August 2012 - 06:44 PM

you missed a bad point :)

look at carefully

if (checkBox2.Checked == false && checkBox3.Checked == false && checkBox4.Checked == false && checkBox5.Checked = false && checkBox6.Checked = false)

last two chekbox has assigned value. (checkbox5 and checkbox5) you need to use == (a comparator which returns bool)

and the another way you can make it easy..

//it returns true but you need false. then use this

if ( ! checkbox1.Checked)

as you see, I dont use ... Checked == true or false..

if I rewrite part of your code

if (!checkBox2.Checked && !checkBox3.Checked & !checkBox4.Checked && !checkBox5.Checked && !checkBox6.Checked)

MessageBox.Show(" Please enter the user requirements");
  • 1

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download