填充datagrid.txt

来自「数据库常用的一些操作方法代码」· 文本 代码 · 共 32 行

TXT
32
字号
			//Open Connection. 
			SqlConnection con = new SqlConnection("server=glf;uid=sa;pwd=;database=northwind");

			//Set the DataAdapter's query.
			da = new SqlDataAdapter("select * from customers", con);
			ds = new DataSet();

			//Fill the DataSet.
			da.Fill(ds, "customers");

			//Set the source table.
			dtSource = ds.Tables["customers"];
			//
			// Set the start and max records. 
			//pageSize = Convert.ToInt32(txtPageSize.Text);
			pageSize=20;
			maxRec = dtSource.Rows.Count;
			PageCount = maxRec / pageSize;

			//Adjust the page number if the last page contains a partial page.
			if ((maxRec % pageSize) > 0) 
			{
				PageCount += 1;
			}

			// Initial seeings
			currentPage = 1;
			recNo = 0;

			// Display the content of the current page.
			LoadPage();

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?