satheesh babu

satheesh babu

  • NA
  • 128
  • 312.1k

fetching the date from data base by creating class

Jan 16 2009 12:18 AM

Hi all,

Here i wrote some code in c# to fetch the mobile numbers from data base
and then i stored all the numbers into one string after that i append this string
to one url like below.

url1 = "http://xxx.xx.xxx.xx:xxxx/xxxxx/xxxxxxSMS.jsp?usr=xxxxxxx&pass=xxxxxxx&msisdn="
+ mob.ToString() + "&msg=" + message + "&sid=xxxxxxx&fl=0&mt=0";

and after creating url i am sending this url using httpwebrequest.

below i am pasting my total code.

Now my QUERY is can we create a class writing this total code and after creating dll

i want to create assembly in sql server 2005 and then i need to schedule this assembly which
is created in sql server 2005 for sending SMS automatically every day.

Please help me.

Below is my CODE

string strConnection = ConfigurationManager.AppSettings["sqlcon"].ToString();
try
{
SqlConnection conn = new SqlConnection(strConnection);
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "BYREGBIRTHDAY";

cmd.Parameters.Add("@status", SqlDbType.Int);
cmd.Parameters[0].Direction = ParameterDirection.Output;

SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataSet ds = new DataSet();
da.Fill(ds, "MembershipRegistration");

int check = Convert.ToInt32(cmd.Parameters[0].Value.ToString());

if (check != 0)
{
for (int j = 0; j <= ds.Tables[0].Rows.Count - 1; j++)
{
str.Append(ds.Tables[0].Rows[j][0].ToString());
}
string mob = str.tostring();
string message = "Wishing you Happy Birthday";

url1 = "http://xxx.xx.xxx.xx:xxxx/xxxxx/xxxxxxSMS.jsp?usr=xxxxxxx&pass=xxxxxxx&msisdn=" + mob.ToString() + "&msg=" + message + "&sid=xxxxxxx&fl=0&mt=0";


try
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url1);
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
Stream st = resp.GetResponseStream();
StreamReader sr = new StreamReader(st);
string buffer = sr.ReadToEnd();

sr.Close();
st.Close();




}
catch (Exception Ex)
{
Response.Write(Ex.Message);
}
}

thank you