Saturday, November 28, 2009

Web Application : C# Function for Insert,get data and fill the dropdown list

//To get data from database
public object getdata(string str)
{
string constr;
constr = "ConnectionString";
SqlConnection con = new SqlConnection(constr);
con.Open();
object a;
SqlCommand cmd = new SqlCommand(str,con);
a = cmd.ExecuteScalar();
con.Close();
return a;
}
//To inserting data into the database
public void insertdata(string str)
{
string constr;
constr = "ConnectionString";
SqlConnection con = new SqlConnection(constr);
con.Open();
SqlCommand cmd = new SqlCommand(str,con);
cmd.ExecuteNonQuery();
con.Close();
}
//To fill the dropdownlist
public void dataset(DropDownList ddl,string str)
{
string constr;
constr = "ConnectionString";
SqlConnection con = new SqlConnection(constr);
SqlDataAdapter dap = new SqlDataAdapter(str, con);
con.Open();
DataSet ds = new DataSet();
dap.Fill(ds);
ddl.Items.Add("Select Option");
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
if(!string.IsNullOrEmpty(ds.Tables[0].Rows[i].ItemArray[0].ToString()))
{
ddl.Items.Add(ds.Tables[0].Rows[i].ItemArray[0].ToString());
}
}
con.Close();
}

Tuesday, November 24, 2009

free sms webservice to send sms using way2sms

http://www.aswinanand.com/sendsms.php(WEBSERVICE)
Now go through this link : http://www.aswinanand.com/2008/07/send-free-sms-web-service/

By the above web service link any one can able to send free sms through ASP.Net code via way2sms.
Implementation of webservice in our code:
Before using you should create way2sms account to use this webservice.

Method to add webreference in visual studio:

1.Right click ur project and click AddWebReference and paste the above top link in it then it will produce xml code below and click ok.
then follow/use the below code

you can write below code in Button event for trial purpose..
com.aswinanand.www.SendSMS sms = new com.aswinanand.www.SendSMS();
sms.sendSMSToMany("ur way2sms username","password","to number","message");

Please go with this url :
http://way2sms.codeplex.com/