Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using MySql.Data.MySqlClient;
- using System.Data;
- namespace DBConnectionTest
- {
- class Program
- {
- static void Main(string[] args)
- {
- string connectionString = "datasource=localhost;port=3306;username=root;password=ece426spring2017";
- String getStringCmd = "SELECT first_name FROM sakila.actor";
- MySqlConnection connection = new MySqlConnection(connectionString);
- MySqlDataAdapter da = new MySqlDataAdapter(getStringCmd, connection);
- DataSet ds = new DataSet();
- da.Fill(ds);
- List<string> keyValues = new List<string>();
- foreach (DataRow row in ds.Tables[0].Rows)
- {
- keyValues.Add(row["first_name"].ToString());
- }
- string a = "and abc asd dsa efg";
- string matchedKeys = string.Empty;
- bool matchFound = false;
- foreach (string key in keyValues)
- {
- if (a.Contains(key))
- {
- matchFound = true;
- matchedKeys += key + ",";
- }
- }
- if (matchFound)
- Console.Write("MATCH");
- else
- Console.WriteLine("NO MATCH");
- //var list = new List<string>();
- //MySqlCommand command = new MySqlCommand(getStringCmd, connection);
- //connection.Open();
- //MySqlDataReader reader = command.ExecuteReader();
- //while (reader.Read())
- //{
- // list.Add(reader["first_name"].ToString());
- //}
- //reader.Close();
- //Console.Write(list);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement