C#:通用数据库 [英] C#: Common Database

查看:86
本文介绍了C#:通用数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是数据库应用程序的新手.我有一个问题.假设我有一个在局域网上的10台PC上运行的应用程序. PC上的每个用户都输入和检索数据.

是否可以仅使用ConnectionString来实现此功能?
这意味着给出服务器上的数据库地址,该服务器是LAN上的10台PC之一.

I am new to Database applications. I have one question. Suppose I have an application which is running on 10 PCs which are on the LAN. Each user on their PC enters and retrieves data.

Can I achieve this functionality by just using ConnectionString?
This means giving the address of database on the Server which is one of the 10 PCs on the LAN.

推荐答案

是的.有点.

您将拥有一个ConnectionString,它提供数据库的地址和登录详细信息,但是之后,您需要提供代码或浏览器html来访问数据库本身并输入/提取记录.

注意,我建议对于DB,您可以查看MsSql或MySql,但是避免使用Access,因为后者在多用户环境中可能很难工作.另外两个都已经习惯了!


我似乎很难,我必须使用TCP/IP和ETC....
但是感谢上帝和感谢您回答,只是ConnectionString可以完成整个操作.........
非常感谢.........-Pritesh Aryan 1分钟前"



不太困难:最基本的是:
Yes. Sort of.

You would have a ConnectionString which supplies the address and login details for the database, but after that you need to supply code or browser html to access the database itself and enter / extract the records.

Note I would suggest that for the DB you look at MsSql or MySql, but avoid Access as the latter can be difficult to work int a multiuser environment. The other two are well used to it!


"i seems it was to difficult, i have to use TCP/IP and ETC....
But thank GOD and Thank for Answering that Just ConnectionString Do the whole the thing.........
thanks a lot......... - Pritesh Aryan 1 min ago"



It''s not too difficult: at it''s most basic:
DataSet ds = new DataSet();
string sql = "SELECT * FROM myTable";
using (SqlConnection conn = new SqlConnection(connectionString)) 
   {
   conn.Open();
   using (SqlDataAdapter da = new SqlDataAdapter(sql, conn)) 
      {
      da.Fill(ds);
      }
   }
myDatagridview.DataSource = ds;

将从"myTable"表中读取所有记录,并将它们显示在WinForms中.类似的代码适用于基于浏览器的系统.

您需要阅读以下内容:Web上有很多东西,但是尝试从MSDN开始并看一下SQLConnection,它至少会为您提供基础知识(如果不是更好的话,那么您将需要一个又大又厚的书!)

Will read all records from the "myTable" table and display them in WinForms. Similar code works for browser based systems.

You need to read up on this: there is a lot on the web, but try starting with MSDN and look at SQLConnection, it will at least give you the basics (if not the finer points - for that you will need a big, thick book!)


这篇关于C#:通用数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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