這可以通過覆蓋以下屬性來實現。 步驟。
轉到設置
點擊查看代碼
鑑於代碼添加以下代碼
Vb時,淨
Default Public Overrides Property Item(ByVal propertyName As String) As Object
Get
If propertyName = "MyConnectionString" Then
Return MyBase.Item(propertyName) & ";Password=Yourpassword;"
End If
Return MyBase.Item(propertyName)
End Get
Set(ByVal value As Object)
MyBase.Item(propertyName) = value
End Set
End Property
C#(Roug
myDataSet myData = new myDataSet();
myDataSetTableAdapters.myTableAdapter myInfo =
new myDataSetTableAdapters.myTableAdapter();
myInfo.Connection.ConnectionString += ";Password=myPassword";
myInfo.Fill(myData.Info);
您可以自由設置中的TableAdapter的ConnectionString的任何部分:使用代碼轉換器)
public override object this[string propertyName] {
get {
if (propertyName == "MyConnectionString") {
return base.Item(propertyName) + ";Password=Yourpassword;";
}
return base.Item(propertyName);
}
set { base.Item(propertyName) = value; }
}