connection object & some ado.net part getting some error while insert to the data,first of all here is my PHP coding part.Here i'm going to convert php codings to .net
openConn();
//<user> slett <slettID>
if((sizeof($MessageArray)==3) && (strtolower($MessageArray[1])=='slett'))
{
$user_id=$MessageArray[2];
if ((int)$user_id > 0)
{
$username=$MessageArray[0];
$QueryCheckMak = "SELECT COUNT(*) FROM XYZ WHERE id='$user_id'";
$QueryCheckMak = odbc_exec($conn, $QueryCheckMak) or die("Query error");
$user_number = odbc_result($QueryCheckMak, 1);
if($user_number=="0")
{
$message_out = "SOME ERROR OUT ";
}
Below coding is my try to convert it.I successfully convert.sizeof part & string to lower case part.below that here coding part is used ODBC connection but in my case i sue sql server connection
public partial class SeenSMS : System.Web.UI.UserControl
{
public SqlConnection mycon;
SqlConnection con = new SqlConnection(@"Data Source=DSOFT\DOMZ;Initial Catalog=Vilt;UserID=sa;Password=sa123");
protected void Page_Load(object sender, EventArgs e)
{
string[] msg_arr = Request.QueryString["arr"].Split('|');
if (!IsPostBack)
{
string Moose = Request.QueryString[1];
}
if (msg_arr != null)
{
if ((msg_arr.Length == 3) && (msg_arr[1].ToLower() == "slett"))
{
int user_id = Convert.ToInt32(msg_arr[2]);
if(user_id > 0)
{
string username = msg_arr[0];
SqlDataReader rdr = null;
con.open();
SqlCommand cmd = new SqlCommand("SELECT COUNT(*) FROM XYZ WHERE id='$user_id",con);
if(user_number =='0')
{
Response.WriteLine("ERROR");
// else part here
}
}
}
}
}