⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.cs

📁 模糊查询 c#程序 具体自己看源代码
💻 CS
📖 第 1 页 / 共 2 页
字号:
			// 
			// btnPre
			// 
			this.btnPre.Location = new System.Drawing.Point(64, 200);
			this.btnPre.Name = "btnPre";
			this.btnPre.Size = new System.Drawing.Size(24, 23);
			this.btnPre.TabIndex = 12;
			this.btnPre.Text = "<";
			this.btnPre.Click += new System.EventHandler(this.btnPre_Click);
			// 
			// btnFirst
			// 
			this.btnFirst.Location = new System.Drawing.Point(32, 200);
			this.btnFirst.Name = "btnFirst";
			this.btnFirst.Size = new System.Drawing.Size(32, 23);
			this.btnFirst.TabIndex = 13;
			this.btnFirst.Text = "|<";
			this.btnFirst.Click += new System.EventHandler(this.btnFirst_Click);
			// 
			// textBox1
			// 
			this.textBox1.Location = new System.Drawing.Point(96, 16);
			this.textBox1.Name = "textBox1";
			this.textBox1.Size = new System.Drawing.Size(112, 21);
			this.textBox1.TabIndex = 14;
			this.textBox1.Text = "";
			// 
			// oleDbDataAdapter1
			// 
			this.oleDbDataAdapter1.DeleteCommand = this.oleDbDeleteCommand1;
			this.oleDbDataAdapter1.InsertCommand = this.oleDbInsertCommand1;
			this.oleDbDataAdapter1.SelectCommand = this.oleDbSelectCommand1;
			this.oleDbDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
																										new System.Data.Common.DataTableMapping("Table", "authors", new System.Data.Common.DataColumnMapping[] {
																																																				   new System.Data.Common.DataColumnMapping("au_id", "au_id"),
																																																				   new System.Data.Common.DataColumnMapping("au_lname", "au_lname"),
																																																				   new System.Data.Common.DataColumnMapping("au_fname", "au_fname")})});
			this.oleDbDataAdapter1.UpdateCommand = this.oleDbUpdateCommand1;
			// 
			// oleDbSelectCommand1
			// 
			this.oleDbSelectCommand1.CommandText = "SELECT au_id, au_lname, au_fname FROM authors WHERE (city LIKE ?)";
			this.oleDbSelectCommand1.Connection = this.oleDbConnection1;
			this.oleDbSelectCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("city", System.Data.OleDb.OleDbType.VarChar, 20, "city"));
			// 
			// oleDbInsertCommand1
			// 
			this.oleDbInsertCommand1.CommandText = "INSERT INTO authors(au_id, au_lname, au_fname) VALUES (?, ?, ?); SELECT au_id, au" +
				"_lname, au_fname FROM authors WHERE (au_id = ?)";
			this.oleDbInsertCommand1.Connection = this.oleDbConnection1;
			this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("au_id", System.Data.OleDb.OleDbType.VarChar, 11, "au_id"));
			this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("au_lname", System.Data.OleDb.OleDbType.VarChar, 40, "au_lname"));
			this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("au_fname", System.Data.OleDb.OleDbType.VarChar, 20, "au_fname"));
			this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Select_au_id", System.Data.OleDb.OleDbType.VarChar, 11, "au_id"));
			// 
			// oleDbUpdateCommand1
			// 
			this.oleDbUpdateCommand1.CommandText = "UPDATE authors SET au_id = ?, au_lname = ?, au_fname = ? WHERE (au_id = ?) AND (a" +
				"u_fname = ?) AND (au_lname = ?); SELECT au_id, au_lname, au_fname FROM authors W" +
				"HERE (au_id = ?)";
			this.oleDbUpdateCommand1.Connection = this.oleDbConnection1;
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("au_id", System.Data.OleDb.OleDbType.VarChar, 11, "au_id"));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("au_lname", System.Data.OleDb.OleDbType.VarChar, 40, "au_lname"));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("au_fname", System.Data.OleDb.OleDbType.VarChar, 20, "au_fname"));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_au_id", System.Data.OleDb.OleDbType.VarChar, 11, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "au_id", System.Data.DataRowVersion.Original, null));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_au_fname", System.Data.OleDb.OleDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "au_fname", System.Data.DataRowVersion.Original, null));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_au_lname", System.Data.OleDb.OleDbType.VarChar, 40, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "au_lname", System.Data.DataRowVersion.Original, null));
			this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Select_au_id", System.Data.OleDb.OleDbType.VarChar, 11, "au_id"));
			// 
			// oleDbDeleteCommand1
			// 
			this.oleDbDeleteCommand1.CommandText = "DELETE FROM authors WHERE (au_id = ?) AND (au_fname = ?) AND (au_lname = ?)";
			this.oleDbDeleteCommand1.Connection = this.oleDbConnection1;
			this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_au_id", System.Data.OleDb.OleDbType.VarChar, 11, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "au_id", System.Data.DataRowVersion.Original, null));
			this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_au_fname", System.Data.OleDb.OleDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "au_fname", System.Data.DataRowVersion.Original, null));
			this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_au_lname", System.Data.OleDb.OleDbType.VarChar, 40, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "au_lname", System.Data.DataRowVersion.Original, null));
			// 
			// oleDbConnection1
			// 
			this.oleDbConnection1.ConnectionString = @"Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=pubs;Data Source=yinlimin;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=YINLIMIN;Use Encryption for Data=False;Tag with column collation when possible=False";
			// 
			// dsAuthors1
			// 
			this.dsAuthors1.DataSetName = "dsAuthors";
			this.dsAuthors1.Locale = new System.Globalization.CultureInfo("zh-CN");
			this.dsAuthors1.Namespace = "http://www.tempuri.org/dsAuthors.xsd";
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(264, 253);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.textBox1,
																		  this.btnFirst,
																		  this.btnPre,
																		  this.btnLast,
																		  this.btnNext,
																		  this.btnshow,
																		  this.txtfname,
																		  this.txtlname,
																		  this.txtID,
																		  this.label5,
																		  this.label4,
																		  this.label3,
																		  this.label2,
																		  this.label1});
			this.Name = "Form1";
			this.Text = "Form1";
			((System.ComponentModel.ISupportInitialize)(this.dsAuthors1)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}
		int iCnt;
		void ShowPosition()
		{
			int iPos;
			if(iCnt == 0) 
			{
				//如果数据集中没有记录则显示“无记录”
				label5.Text ="无记录";
			}
			else
			{
				iPos = this.BindingContext[dsAuthors1, "authors"].Position + 1;
				label5.Text = iPos.ToString() + "of" + iCnt.ToString();
				//如果有则以类似于“1 of 10”表示记录位置
			}
		}

		private void btnshow_Click(object sender, System.EventArgs e)
		{
			string tempstr;
			tempstr="%"+this.textBox1.Text+"%";
			oleDbDataAdapter1.SelectCommand.Parameters[0].Value = tempstr;
			dsAuthors1.Clear();
			oleDbDataAdapter1.Fill(dsAuthors1);

			iCnt=this.BindingContext[dsAuthors1,"authors"].Count;
			this.BindingContext[dsAuthors1, "authors"].Position=0;
			ShowPosition();

		}

		private void btnFirst_Click(object sender, System.EventArgs e)
		{
			this.BindingContext[dsAuthors1, "authors"].Position= 0;
			ShowPosition();


		}

		private void btnPre_Click(object sender, System.EventArgs e)
		{
			if (this.BindingContext[dsAuthors1, "authors"].Position >= 1)
			{  
				//导航到上一条记录
				this.BindingContext[dsAuthors1, "authors"].Position -= 1;
				//显示当前记录在数据集中的位置
				ShowPosition();
			}

		}

		private void btnNext_Click(object sender, System.EventArgs e)
		{
			if (this.BindingContext[dsAuthors1, "authors"].Position< iCnt - 1)
			{  
				//导航到下一条记录
				this.BindingContext[dsAuthors1, "authors"].Position+= 1;
				//显示当前记录在数据集中的位置
				ShowPosition();
			}

		}

		private void btnLast_Click(object sender, System.EventArgs e)
		{
			this.BindingContext[dsAuthors1, "authors"].Position=iCnt-1;
			ShowPosition();

		}
	}
}

⌨️ 快捷键说明

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