这可以通过覆盖以下属性来实现。 步骤。
转到设置
点击查看代码
鉴于代码添加以下代码
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; }
}