[VB2005]關於Configuration的問題
我是使用VB2005專案,用VB2005連上MySQL資料庫
以下是我的程式碼
Imports System.Data.Odbc
Public Class personal_form1
Private Sub personal_form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim cn As OdbcConnection = New
OdbcConnection(System.Configuration.ConfigurationManager.ConnectionStrings("cn").ConnectionString)
Dim com As OdbcCommand = New OdbcCommand(String.Empty, cn)
cn.Open()
com.CommandText = "select count(*) from text"
Label1.Text = com.ExecuteScalar().ToString()
com.CommandText = "INSERT INTO text (context) values ('test')"
com.ExecuteNonQuery()
cn.Close()
End Sub
執行時System.Configuration.ConfigurationManager發生例外
顯示ConfigurationManager不是Configuration的成員
app.config裡面的DATABASE、UID、PWD都改過了
用的是MySQL ODBC 3.51 Driver
想請教我該如何將它加入成員?或是解決這個例外呢??
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.220.30.237
推
11/19 11:46, , 1F
11/19 11:46, 1F
→
11/19 11:46, , 2F
11/19 11:46, 2F
<connectionStrings>
<add name="cn" connectionString="DRIVER={MySQL ODBC 3.51
Driver};SERVER=localhost;DATABASE=royal;UID=root;PWD=;OPTION=3;stmt=SET
NAMES GB2312;"/>
</connectionStrings>
系統管理工具,資料來源(ODBC)裡的驅動程式
確定已設定為MySQL ODBC 3.51 Driver了
※ 編輯: wu0613 來自: 61.220.30.237 (11/19 12:01)
※ 編輯: wu0613 來自: 61.220.30.237 (11/19 13:30)
推
11/19 14:32, , 3F
11/19 14:32, 3F
→
11/19 15:11, , 4F
11/19 15:11, 4F
→
11/20 09:50, , 5F
11/20 09:50, 5F
→
11/20 11:03, , 6F
11/20 11:03, 6F