我有一个很长的select语句,包含很多参数和Inner join。
我的第一个问题:有没有办法让它更有效率?
我的第二个问题是它为什么不在文本框中显示任何内容? 德尔>
我的目标是展示来自搜索的房子。 德尔>
用户首先选择组合框中的所有内容(所有参数)然后我的选择通过表格属性并显示文本框中可用的房屋
clsDataSource.mycon = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\...");
clsDataSource.mycon.Open();
OleDbCommand mycmd = new OleDbCommand("SELECT AreaSize.*, Bathrooms.*, Cities.*, Prices.*,Properties.*, Rooms.*, Types.*, Users.* FROM Users INNER JOIN (Types INNER JOIN (Rooms INNER JOIN (Prices INNER JOIN (Cities INNER JOIN (Bathrooms INNER JOIN (AreaSize INNER JOIN Properties ON AreaSize.AreaSizeID = Properties.AreaSize) ON Bathrooms.BathroomID = Properties.Bathrooms) ON Cities.CityID = Properties.City) ON Prices.PriceID = Properties.Price) ON Rooms.RoomID = Properties.Rooms) ON Types.TypeID = Properties.PropertyType) ON Users.UserID = Properties.AgentID WHERE Properties.PropertyType=@propertyType AND Properties.City=@city AND Properties.Rooms=@rooms AND Properties.AreaSize=@areasize AND Properties.Price=@price AND Properties.Bathrooms=@bathrooms AND (Properties.BoolAgent = true)", clsDataSource.mycon);
mycmd.Parameters.Add("@city", OleDbType.Integer, 3).Value = clsHouses.location;
mycmd.Parameters.Add("@propertyType", OleDbType.Integer, 3).Value = clsHouses.type;
mycmd.Parameters.Add("@rooms", OleDbType.Integer, 3).Value = clsHouses.bedrooms;
mycmd.Parameters.Add("@areasize", OleDbType.Integer, 3).Value = clsHouses.surface;
mycmd.Parameters.Add("@price ", OleDbType.Integer, 3).Value = clsHouses.price;
mycmd.Parameters.Add("@bathrooms", OleDbType.Integer, 3).Value = clsHouses.bathrooms;
myadaptS = new OleDbDataAdapter(mycmd);
myadaptS.Fill(clsDataSource.myset, "ResultSearch");
tbSearchResult = clsDataSource.myset.Tables["Properties"];
txtType.Text = tbSearchResult.Rows[idx]["DescriptionType"].ToString();
答案 0 :(得分:0)
clsDataSource.mycon = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\...");
clsDataSource.mycon.Open();
clsDataSource.myset = new DataSet();
current = 0;
OleDbCommand mycommand = new OleDbCommand("SELECT AreaSize.*, Bathrooms.*, Cities.*, Prices.*,Properties.*, Rooms.*, Types.*, Users.* FROM Users INNER JOIN (Types INNER JOIN (Rooms INNER JOIN (Prices INNER JOIN (Cities INNER JOIN (Bathrooms INNER JOIN (AreaSize INNER JOIN Properties ON AreaSize.AreaSizeID = Properties.AreaSize) ON Bathrooms.BathroomID = Properties.Bathrooms) ON Cities.CityID = Properties.City) ON Prices.PriceID = Properties.Price) ON Rooms.RoomID = Properties.Rooms) ON Types.TypeID = Properties.PropertyType) ON Users.UserID = Properties.AgentID WHERE Properties.PropertyType=@propertyType AND Properties.City=@city AND Properties.Rooms=@rooms AND Properties.AreaSize=@areasize AND Properties.Price=@price AND Properties.Bathrooms=@bathrooms AND (Properties.BoolAgent = true)", clsDataSource.mycon);
mycommand.Parameters.Add("@propertyType", OleDbType.Integer).Value = clsHouses.type;
mycommand.Parameters.Add("@city", OleDbType.Integer).Value = clsHouses.location;
mycommand.Parameters.Add("@rooms", OleDbType.Integer).Value = clsHouses.bedrooms;
mycommand.Parameters.Add("@areasize", OleDbType.Integer).Value = clsHouses.surface;
mycommand.Parameters.Add("@price", OleDbType.Integer).Value = clsHouses.price;
mycommand.Parameters.Add("@bathrooms", OleDbType.Integer).Value = clsHouses.bathrooms;
mycommand.Parameters.Add("@address", OleDbType.VarChar).Value = txtAddress.Text;
mycommand.Parameters.Add("@description", OleDbType.VarChar).Value = txtDescription.Text;
mycommand.CommandType = CommandType.Text;
myadaptL = new OleDbDataAdapter(mycommand);
myadaptL.Fill(clsDataSource.myset, "Properties");
tbListing = clsDataSource.myset.Tables["Properties"];
//FillCombobox();
TAB2TXT(current);