SQL指令修改(歌星轉歌曲)
This commit is contained in:
parent
533cc9eb4a
commit
9f517c54d4
@ -1970,10 +1970,8 @@ public class MultiPagePanel : Panel
|
||||
artistLabel.Click += (sender, e) =>
|
||||
{
|
||||
string searchText = artistLabel.Text; // 取得輸入內容
|
||||
|
||||
// 根據輸入的注音篩選歌曲清單
|
||||
var searchResults = PrimaryForm.Instance.allSongs.Where(song => song.ArtistA.StartsWith(searchText) || song.ArtistB.StartsWith(searchText)).ToList();
|
||||
|
||||
string query = $"SELECT * FROM SongLibrary WHERE `歌星 A` = '{searchText}' OR `歌星 B` = '{searchText}'";
|
||||
List<SongData> searchResults = PrimaryForm.Instance.SearchSongs_Mysql(query);
|
||||
// 重置分頁
|
||||
PrimaryForm.Instance.currentPage = 0;
|
||||
currentSongList = searchResults;
|
||||
|
@ -546,18 +546,19 @@ namespace DualScreenDemo
|
||||
/// 查詢歌曲(字數查詢),連接資料庫並執行 SQL 查詢。
|
||||
/// </summary>
|
||||
private void FindWordCountSongs(){
|
||||
string searchText = inputBoxWordCountSongs.Text;
|
||||
// 在這裡添加搜尋歌曲的邏輯
|
||||
// 例如:根據輸入框的內容搜尋歌曲
|
||||
string query = "SELECT * FROM SongLibrary WHERE CHAR_LENGTH(歌曲名稱) = @searchLength ";
|
||||
string searchText = inputBoxWordCountSongs.Text;
|
||||
string query;
|
||||
if (int.TryParse(searchText, out int length))
|
||||
{
|
||||
query= $"SELECT * FROM SongLibrary WHERE CHAR_LENGTH(歌曲名稱) = {length} ";
|
||||
query = $"SELECT * FROM SongLibrary WHERE CHAR_LENGTH(歌曲名稱) = {length} ";
|
||||
}
|
||||
else
|
||||
{
|
||||
// 處理輸入錯誤,例如顯示提示訊息
|
||||
//MessageBox.Show("請輸入正確的數字!");
|
||||
query = string.Empty; // 清空查詢
|
||||
return;
|
||||
}
|
||||
List<SongData> searchResults = SearchSongs_Mysql(query);
|
||||
|
@ -146,7 +146,7 @@ namespace DualScreenDemo
|
||||
public List<SongData> SearchSongs_Mysql(string query)
|
||||
{
|
||||
List<SongData> searchResults = new List<SongData>();
|
||||
|
||||
Console.WriteLine(query);
|
||||
string connectionString = "Server=192.168.22.170;Port=3306;Database=Karaoke-Kingpin;User=Karaoke-Kingpin;Password=ESM7yTPMnavFmbBH;";
|
||||
|
||||
using (var connection = new MySqlConnection(connectionString))
|
||||
|
Loading…
x
Reference in New Issue
Block a user