我在Visual Studio 2012中連接到Sql Server 2008 R2的基本應用程序,但現在我希望它僅連接到MySQL數據庫(其表和列是相同)。將Visual Studio 2012中的數據源從SQLSRV更改爲MySQL
我下載了MySQL for Visual Studio,並在數據源中成功連接到MySQL中的數據庫。
現在我想問一下,如果它只對數據庫執行簡單的CRUD操作,應該從我的應用程序(除了連接字符串)更改哪些內容?
比如我更改連接字符串和當應用程序試圖以dB爲單位來搜索和填充數據集,我發現在這個代碼中的錯誤:
SqlDataAdapter dataAdapter = database.getPaquetes(date, _destino);
SqlCommandBuilder commandBuilder = new SqlCommandBuilder(dataAdapter);
DataSet ds = new DataSet();
dataAdapter.Fill(ds);
dgv_paqdisp.ReadOnly = true;
dgv_paqdisp.DataSource = ds.Tables[0];
錯誤:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server).
是這些類型只適用於SQL Server?如果是的話,使用MySQL時什麼是等效的?
注意我不想讓你重新編寫我的代碼或任何東西,我只想知道是否有我丟失的東西,或者如果它不是那麼簡單的改變DataSource?提前致謝。
我終於改變了它,我可以做一個插入,但在選擇數據和填充要在數據網格視圖中顯示的數據集的時候,我發現有這個錯誤: '非法混合整理(utf8_general_ci, COURCIBLE)和(latin1_swedish_ci,NUMERIC)操作'> =''正好在這一行上'DataSet ds = new DataSet(); dataAdapter.Fill(ds);' – mlqmarkos12
試試這個http://stackoverflow.com/a/13285681/713789 – Adrian