Monday, 17 June 2013

connect to sql database using c#
add these library first
using System.Data;
using System.Data.SqlClient;


create string to connect with database
string  str = @"Data Source=(local);Initial Catalog=database;Persist Security Info=True;User ID=username;Password=password";



 SqlConnection con = new SqlConnection(); //create object to connect sql
    SqlCommand cmd = new SqlCommand(); // create object to send command in sql
    DataTable dt = new DataTable();  //create object to store data in temprary
      con.ConnectionString = str; //it open connection for database
        cmd.Connection = con; // it make connection between connection and command
        SqlDataAdapter da = new SqlDataAdapter(cmd); //adatapter object to talk database
            con.Open();//open connection
            cmd.CommandText = "insert into table(comuln1,column2)values('a','b')"; // specify command
            da.Fill(dt);//fire command
con.close();//close connection

//note: if id column is auto then no need to specify id column name to insert


now read database from sql database
create connection as above

System.Data.SqlClient.SqlDataReader SqlDR; // create object to read database
       
  con.Open();
            cmd.CommandText = "SELECT column1,column2 FROM table";
            System.Data.SqlClient.SqlDataReader SqlDR2;
            SqlDR = cmd.ExecuteReader();

            while (SqlDR.Read())
            {

                complainno = SqlDR["column1"].ToString();

            }
            con.Close();



create database in windows application

here is in image given below  you can view how to create sql datbase in windows application.





READ GROUP EMAIL USING C#.

first Create table for user id and password.
like this below

tablae name : emailusers :
1. id int unique
2. userid nvarchar 50
3. pass nvarchar 50



when Timer starts. //set timer as you need
read all userid and password from table that you create by for loop like this below
create connection and retreive all users with pass in grid.
then
do this code
int a;
a=grid.rows.count; //grid is id of gridview
for(int i=0;i<a;i++)
{
string id =grid.rows[i].cell[0].value.tostrig()
string uid = grid.rows[i].cell[1].value.tostrig()
string pass =grid.rows[i].cell[2].value.tostrig()

readmail(uid,pass); //call read mail function

}

public string (string uid,string pass)
{
//use link below to see code to read email inbox
http://ramveersingh.wordpress.com/2011/05/17/get-unread-mail-count-of-gmail-in-c/
//and insert node data from xml in your table
//and all email will insert in your table from all accounts using this code.
//its very easy.

return uid;

}

Saturday, 8 June 2013

Send and Receive SMS in .NET using GSM modem


This source code is for Send and Receive SMS in .NET using GSM modem. You can use this SMS Application program to send SMS from your PC using GSM modem connected to your computer. Its complete working project code for sending and receiving sms using C#.Net. You can implement this project source code to your project and this is very much useful for college students.

Steps to Send and Receive SMS in .NET using GSM modem

First, connect GSM modem to your PC.
Check port connection
Open the application.
Configure the port settings.




By using this program user can collect email addresses from local .txt files documents or any non-binary file.
select any text file, application will extract all valid email address from text file



Chat Application (connecting winforms to webapp chat service)
Features:
1. Chat Application Sample to connect your Winform Application to Web App Chat service
Useful with following Scenarios
1. Realtime based apps
2. if you want your client application(be it web or winform apps) to get notified when data has changes
3. of course can be used as chat application can be suited on any type of application(web, agent service or winforms)
System Requirements:
1. Windows XP, Windows Vista, Windows 7, Windows Server 2003, 2005 OR HIGHER
2. CPU(Intel,Amd) 1ghz or higher
3. RAM 512 mb or higher (1gig recommended)
Requirements for IDE:
1. C# VS STUDIO 2012 Professional Edition
NOTE: I have provided the whole source code for it, for you to explore.




This application calculates your waist to hip ratio and gives you the results to two decimal places. It also gives you the results accurate for your sex. It groups the results into three categories of excellent, average, or poor, depending on the value and then gives corresponding health advice.
Increasingly doctors see waist to hip ratio as a more accurate measurement of health/fitness than the BMI.
This is a windows Waist to Hip Ratio Calculator desktop application. I wrote it in C# and used Visual studio 2012 on .NET framework 4.5. it is a WPF application.