且构网

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

C#:通用数据库

更新时间:2023-02-08 17:52:19

是的.有点.

您将拥有一个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!)