本文介绍了如何从ms表中获取数据从ms访问形式相同的数据库(搜索查询)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 限时删除!! 您好, 我想从MS访问数据库中获取数据。数据库名称记录和表名称区域(SNO,AreaCode,代码)城市(SNO,名称,城市代码)我想在SNO的基础上进行单一搜索单一搜索查询 请告诉我,我有代码从一张桌子获取数据并在一张桌子上搜索我想为两张桌子制作 我尝试了什么: OleDbConnection mycnc = new OleDbConnection( Provider = Microsoft.Ace.OLEDB.12.0; Data Source = F:\\Database1.accdb); OleDbDataAdapter myadpt = new OleDbDataAdapter(); DataSet mydtSet = new DataSet(); myadpt.SelectCommand = new OleDbCommand(); myadpt.SelectCommand.CommandText = 从SNO = + textBox1.Text + ; myadpt.SelectCommand.Connection = mycnc; mycnc.Open(); myadpt2.Fill(mydtSet, area); mycnc.Close(); dataGridView1.DataSource = mydtSet; dataGridView1.DataMember = area; MessageBox.Show( 成功搜索!); textBox1.Clear(); 解决方案 我认为你可以使用工会所有的SQL语法 myadpt.SelectCommand.CommandText =select * from SNO =+ textBox1.Text +UNION ALL SELECT * FROM CITY WHERE SNO =+ textbox1。文字+; Hello , I want to get data from tow table from MS access database. Database name Record and table name Area (SNO, AreaCode, Code ) City (SNO, Name , city code ) I want to make a single search single search query on base of SNOKindly tell me i have code which get data from one table and search in one table i want to make for two tableWhat I have tried:OleDbConnection mycnc = new OleDbConnection("Provider=Microsoft.Ace.OLEDB.12.0; Data Source=F:\\Database1.accdb");OleDbDataAdapter myadpt = new OleDbDataAdapter();DataSet mydtSet = new DataSet();myadpt.SelectCommand = new OleDbCommand();myadpt.SelectCommand.CommandText = "select * from area where SNO=" + textBox1.Text + "";myadpt.SelectCommand.Connection = mycnc;mycnc.Open();myadpt2.Fill(mydtSet, "area");mycnc.Close();dataGridView1.DataSource = mydtSet;dataGridView1.DataMember = "area";MessageBox.Show("successfully search !");textBox1.Clear(); 解决方案 i think you can use SQL syntax using union allmyadpt.SelectCommand.CommandText = "select * from area where SNO=" + textBox1.Text + " UNION ALL SELECT * FROM CITY WHERE SNO=" + textbox1.Text + ""; 这篇关于如何从ms表中获取数据从ms访问形式相同的数据库(搜索查询)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 1403页,肝出来的..
09-08 12:46