how to display 2 tables from mysql in visual studio 17

110
December 30, 2018, at 07:30 AM

this is in my controller

 string connStr = "server=" + IpAddress + ";user=" + UserName + ";database=" + DatabaseName + ";port=" + PortNumber + ";password=" + Password + ";SslMode=none;";
 MySqlConnection conn = new MySqlConnection(connStr);
 conn.Open();
 string query = " select * from Cities,Regions";
 MySqlCommand com = new MySqlCommand(query, conn);
 MySqlDataAdapter da = new MySqlDataAdapter(com);
 DataTable ds = new DataTable();
 da.Fill(ds);
 conn.Close();

I use a view model for displaying data from mysql and i fill them as below.

 List<Models.ViewModels.city> CT = new List<Models.ViewModels.city>();
 SftpClient sftpclient = new SftpClient("port", "root", "name");
 sftpclient.Connect();
 foreach (DataRow item in ds.Rows)
 {
     city ct = new city
     {
         CityName = item.itemArray[1].ToString(),
         CityNumber = Convert.ToInt32(item.itemArray[2])
     }
     region rg = new region
     {
         RegionName = item.itemArray[1].ToString(),
         RegionNumber = Convert.ToInt32(item.itemArray[2])
     }
 }
 CT.Add(ct);
 return View(CT.ToList());

How could i show regions in my razor. i already used viewbag for sending a list form my region viewmodel. but it doesn't fill the viewmodel obviously but how should i fill the region viewmodel

Rent Charter Buses Company
READ ALSO
how to Replace date with mysql query

how to Replace date with mysql query

I need a MySQL request to replace the DATE data typeBut when I use where this query doesn't work

129
How to update &amp; delete records using Perl Net::MySQL

How to update & delete records using Perl Net::MySQL

I am spending time trying to get Net:MySQL to work for my database needs but am having trouble finding tutorials on the internet

137
How to write the query to accept the input from the search box and search from MySql db (Wordpress)

How to write the query to accept the input from the search box and search from MySql db (Wordpress)

I'm trying to access data from local wamp server from a Wordpress site using a Search boxI created the search box using the function get_search_form(), and I am unable to write a query in php to access using the same

122