且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SQL Server和Windows窗体应用程序之间的连接

更新时间:2023-02-06 22:44:06

如果您的数据库确实有连接字符串,则只需使用System.Data.SqlClient.SqlCommand类即可.将数据插入表中.您可以从这里开始阅读.
http://www.codeproject.com/Questions/117909/connection-between-SQL-server-and-Windows-form-app.aspx [
If you do have a connection string for your database, you can just use System.Data.SqlClient.SqlCommand class to insert the data to the table. You can start reading from here.
http://www.codeproject.com/Questions/117909/connection-between-SQL-server-and-Windows-form-app.aspx[^]
You create an instance of SqlConnection class, initialize it with your connection string, and run the command on the database.
Regards,
Kemo


如果您在Internet上进行搜索,则会发现大量文章,向您展示如何保存到数据库.

但是,我认为您不会找到任何可以完全满足您需要的文章.

尝试使用其中一篇文章作为知识库来实现自己的东西,如果您遇到任何问题,请在此处将其发布,然后有人会为您提供帮助.
If you do a search on the internet you will find tons of articles that will show you how to save to the database.

I dont,however, think you will find any article that will do exactly what you want.

Try to implement your own stuff using one of these articles as a knowledge base, if you run into any issues post them here and someone will help you.


您好,Abhinav,

感谢您的答复,我对这种编程还很陌生,因此我很难找到答案.我有一个可以连接到COM端口并在控制台窗口中显示它的代码,您能帮我修改一下它在SQL Server中将数据存储在SQL Server中的位置,然后再在控制台窗口中显示它吗?

问候,
斯里尼瓦萨(Srinivasa)
Hi Abhinav,

Thanks for your reply, I''m very new to this kind of programming and so I was finding it difficult to get the answers. I have got a code which does connect to COM port and display it in console window could you help me to modify this where it stores the data in a SQL server before displaying it in the console window?

Regards,
Srinivasa