Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8048639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:30:23+00:00 2026-06-05T06:30:23+00:00

connection object & some ado.net part getting some error while insert to the data,first

  • 0

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
                    }

                }
            }


        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T06:30:25+00:00Added an answer on June 5, 2026 at 6:30 am

    try this:

     SqlCommand cmd = new SqlCommand("SELECT COUNT(*) FROM XYZ WHERE user_id=@user_id,con));
     oCmd.Parameters.AddWithValue("@user_id", user_id);
    
     int user_number = 0;                 
     con.open();
       using (SqlDataReader oReader = cmd.ExecuteReader())
                {                   
                    while (oReader.Read())
                    {
                       user_number =Convert.ToInt32(oReader["count"]);                                                           
                    }
                    myConnection.Close();
                }                   
    
    
    
               if(user_number == 0)
                       {
                     Response.WriteLine("ERROR");
    
                     // else part here
                    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some issues with this: First I create my object and move it
I've made some code to insert data from an excel table in to an
I have this error when I try to save some data to my sql
I am creating a Connection object and making jdbc connection in a constructor of
Is there an easy way to wrap an ADODB.Connection COM object (the one defined
JavaScript object created with a prototype maintains live connection to its prototype, so that
Is model comprises of model object and classes that perform database connection and database
I was wodering if it matter where the connection is made on an object.
I have a parent object (part of a DAL) that contains, amongst other things,
My program uses a NetworkOutput object which can be used to write data to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.