last day (14 days later) » 

10:55 AM
-1
Q: mysql query to List

Atif ShabeerI have a mysql query, example: INSERT INTO `tbl_country` VALUES ('1', 'AFGHANISTAN', '93', '1'); INSERT INTO `tbl_country` VALUES ('2', 'ALBANIA', '355', '1'); INSERT INTO `tbl_country` VALUES ('3', 'ALGERIA', '213', '1'); INSERT INTO `tbl_country` VALUES ('4', 'AMERICAN SAMOA', '1684', '1'); ...

 
Where's the code that execute the query?
 
I have the above mysql query, i want to convert this query into c# list
 
You want to convert the text of the query in c# code that initialize the list?
 
You had already replied, that code is correct, but isnt that hectic to manually fill the list, it will take hours to type all countries.... any 1-3 liner method.?
 
This is not the kind of question to post here, really.
 
10:55 AM
Obviously it is, I need a mySQL-To-LINQ query for this.
Can you please make a mySQL-to-LINQ for it?
 
Obviously NOT! You don't need ANY code to that!
 
what if i had ths mySQL query containing 10 thousand rows of data,
can you please check this:
-4
Q: c# MySql data to list

Henrybasically what I want to do is read data from the table and then add that data to the appropriate list. For example List<int> value; SELECT Values_To_Add FROM table value.add(Values_To_Add) Obviously using the correct C# MySql syntax. How should I go about doing this?

List<int> values = new List<int>();

string sql = "SELECT Values_To_Add FROM table";
command.CommandText = sql;
MySqlDataReader reader = command.ExecuteReader();

while(reader.Read())
{
values.Add(reader["Values_To_Add "]);
}
 
This actually execute the query!!!!!
 
something like this
i actually want to make list from that table,
 
Oh jesus
 
10:59 AM
Look what i am typing:
 
Do you want to execute the query on MySQL and get the result? Or you want "translate" MySQL code to C# code????
 
it will take me hours to convert manually every row of that query to LIST
private void ListPicker_Country() //OPTION 2: GET THIS ACTUAL LIST FROM SERVER SIDE AT FIRSTTIME OPENING OF APP.
{
CountryListObject = new List<CountryWithCodesListClassType>();
//TESTING/DEMO:
CountryListObject.Add(new CountryWithCodesListClassType() { CountryWithCodesGroupItem_ID = 1, CountryWithCodesGroupItem_Symbol = "AF", CountryWithCodesGroupItem_Name = "AFGHANISTAN", CountryWithCodesGroupItem_Code = "+93" });
CountryListObject.Add(new CountryWithCodesListClassType() { CountryWithCodesGroupItem_ID = 2, CountryWithCodesGroupItem_Symbol = "AF", CountryWithCodesGroupItem_Name = "ALBANIA"
want "translate" MySQL code to C# code
 
good, so the example you showed me before has nothing to do with this
 
do you have any website which can provide me readymade c# list of countries
 
because that sample actually executed the code!
just google it!
 
11:01 AM
List<int> values = new List<int>();

string sql = "SELECT Values_To_Add FROM table";
command.CommandText = sql;
MySqlDataReader reader = command.ExecuteReader();

while(reader.Read())
{
values.Add(reader["Values_To_Add "]);
}
this one?
 
THIS EXECUTE THE QUERY ON MYSQL!!!!!!!
 
this example converts sql-query to values list
same is what i want
am i not able to make you understand, i think, my english is poor, pardon me
 
I see
Bye
 
ok thanyou
 

last day (14 days later) »