SQL Server和Windows窗体应用程序之间的连接 [英] connection between SQL server and Windows form application

查看:77
本文介绍了SQL Server和Windows窗体应用程序之间的连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我创建了一个Windows窗体应用程序,该应用程序从COM端口接收数据并将其显示在控制台屏幕上.我想先将数据存储在SQL Server数据库中,然后再在控制台屏幕上显示它们.数据应存储在2列中,其中我们必须为其中一列加上时间戳,而另一列则显示来自COM端口的消息.每行应存储从COM端口接收的一行消息.我正在使用Visual c#2010 express和SQL Server 2008评估版.

您能帮我遵循什么程序,请问有一段能解决问题的代码吗?
预先感谢您的帮助.我准备为您提供更多详细信息.

Hi,

I have created an windows form application which receives the data from COM port and displays it on the console screen. I wanted to store the data in SQL server database before dispalying it on the console screen. The data should be stored in 2 columns where we have to timestamp one of the columns and other one displays the message from the COM port. Each row should store one line of message received from the COM port. I am using Visual c# 2010 express and SQL server 2008 Evaluation versions.

Could you please help me what procedure should I follow and do you have a piece of code which does the trick.
Your help is appreciated in advance. I m ready to provide you further details.

推荐答案

如果您的数据库确实有连接字符串,则只需使用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


这篇关于SQL Server和Windows窗体应用程序之间的连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆