Datarepeater 中的文本框动态“数据绑定”

发布于 2024-07-05 06:28:27 字数 335 浏览 5 评论 0原文

我需要知道是否可以将驻留在数据重复器中的文本框动态绑定到“动态”创建的 BindingSource。 我正在使用VB.net。 我使用的数据库是MySQL数据库。

由于数据库不会永久驻留在同一服务器上,因此我必须动态使用连接。

[编辑]
好吧,看来我提问的时候是个傻瓜。 我正在制作的应用程序不是基于网络的。 这是一个简单的(我希望)应用程序,它连接到 MySQL 数据库,访问表,以便我可以编辑/查看它。 当前设置使用“添加数据源”向导。 我已使用 mysql 连接器 dll 成功动态连接到数据库,但没有在设计时将文本框设置到数据源,我不确定如何通过数据重复器“链接”它们。

I need to know if it is possible to dynamically bind a textbox residing within a datarepeater to a 'dynamically' created BindingSource. I am using VB.net. The database I am using is a MySQL database.

I have to use the connection dynamically due to the fact that the database my not permanently reside on the same server.

[edit]
ok, so it seams that I am a dolt when asking questions. The app that I am making is not web based. it is a simple (I hope) app that connects to a MySQL database, accesses a table so I can edit/view it. Current setup is using the Add DataSource wizard. I have successfully connected to the dbase dynamically using the mysql connector dll but without the textboxes set at design time to a datasource, I am unsure on how to 'link' them via the datarepeater.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

◇流星雨 2024-07-12 06:28:27

您的连接字符串应该在 Web.Config 中定义,如果您将数据库移动到不同的服务器,只需修改 web.config 条目即可。 只要保持连接字符串名称相同,BindingSource 对象就会从配置中获取新值。


edit

In truth, the same concept should apply here as it does in the web app answer listed above.

所有数据对象都应该是硬编码的,只有连接字符串(您必须向用户询问,或者在数据库移动时作为更新推出)才会被修改。

例如,在您的项目中创建一个 App.Config 文件。 将您的配置值之一设置为连接字符串。 当您需要时,您可以在该配置值中获取连接字符串。 然后您的向导将允许用户轻松修改连接。

Your connection string should be defined in your Web.Config, and if you move your database to a different server, it's just a matter of modifying the web.config entry. As long as you keep the connection string name the same, the BindingSource object will pick up the new value from the config.


edit

In truth, the same concept should apply here as it does in the web app answer listed above.

All of your data objects should be hard-coded, and it's just the connection string (which you'll have to either ask the user for, or push out as update when the DB moves) which will get modified.

For example, create a App.Config file in your project. Have one of your configuration values be the connection string. This config value will be where you go to get the connection string whenever you need it. Then your wizard will be there to allow users to easily modify the connection.

允世 2024-07-12 06:28:27

然后在 app.config 中查看

连接字符串应该在那里。

如果不是,那么您应该将其放在这里,因为您可以随时更改此文件,而不必重新编译您的应用程序。

then look in app.config

the conenction string should be there.

If it is not then you should put it in here as you can change this file at any time and not have to recompile your app.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文