• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 388
  • Last Modified:

c# mysql try to select but error

when i run this code with phpmyadmin it give 8801 I try it with c# it have and error how can i fix it
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {


            MySqlConnection conDatabase = new MySqlConnection("Data Source=localhost;" +
                                       "Persist Security Info=yes;" +
                                       "UserId=tee; PWD=t5794; database=ph3;" +
                                       "CHARSET=utf8;");
            conDatabase.Open();





            using (MySqlCommand cmd = new MySqlCommand("SELECT COUNT( * ) FROM  `member`  WHERE  `tambol` LIKE  '¿¿¿¿¿¿¿' ", conDatabase))
                {
                    try
                    {
                      

                        int count = (int)cmd.ExecuteScalar();


                        Console.WriteLine(count.ToString());

                    }
                    catch (MySqlException ex)
                    {
                        Console.WriteLine(ex.ToString());
                    }
                }

Open in new window

C-.png
phpmyadmin.png
0
teera
Asked:
teera
  • 2
1 Solution
 
raysonleeCommented:
use long instead of int, executescalar returns int64
0
 
teeraAuthor Commented:
hi raysonlee

it work but
why int is not from -2,000,000 to 2,000,000

it only  8801
0
 
raysonleeCommented:
int is int32, which is from -2,147,483,648 to +2,147,483,647
long is int64, which is from -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807
I suppose ExecuteScalar use int64 so that it can handle query to database with more than 2G records
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now