Hi, I'm trying to retrieve some information from my database, but somehow i get this error:
Behind code:
this is my stored procedure:
I really dont understand why i get the error, hope somebody can help me please
Behind code:
Code:
public void binddata()
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter("getRoomNEquip2", con);
da.SelectCommand.CommandType = CommandType.StoredProcedure;
da.SelectCommand.Parameters.Add("@Location", SqlDbType.VarChar, 50);
da.SelectCommand.Parameters["@Location"].Value = DropDownLocation.SelectedItem.Text;
da.Fill(ds);
ds.Relations.Add("myRelation",
ds.Tables[0].Columns["ID"],
ds.Tables[1].Columns["ID"]);
MeetRoomList.DataSource = ds.Tables[0];
MeetRoomList.DataBind();
}
Code:
ALTER PROCEDURE [dbo].[Getroomnequip2]
@Location VARCHAR(50)
AS
BEGIN
CREATE TABLE #temp
(
name VARCHAR(50),
id INT,
location VARCHAR(50),
fk_type VARCHAR(10),
fk_equipments INT,
TYPE VARCHAR(10),
fk_meetroom INT,
status CHAR(1),
note TEXT,
DATE DATETIME,
fk_user INT,
reg_date DATETIME,
)
INSERT INTO #temp
SELECT roomndato.mrn AS name,
a.id,
a.location,
a.fk_type,
b.fk_equipments,
b.TYPE,
c.fk_meetroom,
c.status,
c.note,
c.fk_user,
c.reg_date,
roomndato.maxdate AS DATE
FROM (meetroom AS a
FULL JOIN meetroomtypes AS b
ON a.fk_type = b.TYPE
FULL JOIN equipmentstatus AS c
ON b.fk_equipments = c.fk_equipments
AND a.id = c.fk_meetroom)
LEFT JOIN (SELECT DISTINCT a.name AS mrn,
MAX(c.DATE) AS maxdate
FROM (meetroom AS a
FULL JOIN meetroomtypes AS b
ON a.fk_type = b.TYPE
FULL JOIN equipmentstatus AS c
ON b.fk_equipments = c.fk_equipments
AND a.id = c.fk_meetroom )
GROUP BY a.name) AS roomndato
ON a.name = roomndato.mrn
AND c.DATE = roomndato.maxdate
WHERE location = @Location
ORDER BY name,
DATE DESC
SELECT DISTINCT name,
id,
TYPE
FROM #temp
SELECT *
FROM #temp
END
DROP TABLE #temp
Comment