Hi, i am doing a web application project using .net visual studio and the database used is called:ms sql server 2008. I am doing a search function whereby user inputs in the name of the items they want to search for and it will be displayed in the grid view.
In the OS_DLL, is where I stored the database cs.
The database code is as follows:
Qn- How do i know which table the database code will retrieve since my database table is called:OS_Items?
This is what I have put at the aspx.cs page:
C#
using System;
using System.Data;
using System.Web.UI;
using
System.Web.UI.WebControls;
using com.vrm.database;
using com.vrm.com;
namespaceonlinestore
{
publicpartialclassItemList :
System.Web.UI.Page
{
private os_database osdb = new
os_database();--This is always in error. but i have alrd define it
private String
viewStateGVName = "gvItem";
//set the index for the columns of
the gridview in the aspx that required formatting of
text
privateconstint GVCHKBOX =
0;
privateconstint GVEDITBTN =
1;
privateconstint GVVENDORBRN =
2;
privateconstint GVMATERIALGRP
= 4;
privateconstint GVINSAP =
8;
privateconstint
GVSTARHUBCONTACTPERSON = 9;
privateconstint GVDELETEFLAG =
16;
privateconstint GVBLOCKED =
17;
//set the const for the ID of the
GV Checkbox column
privateconststring GVCHECKBOXCOLID = "selected";
protectedvoidPage_Load(object sender, EventArgs
e)
{
ViewState[this.ToString() + "_SortExpression"] =
"TemplateName";
ViewState[this.ToString() + "_SortDirection"] = "ASC";
}
protectedvoidbtnClear_Click(object sender, EventArgs
e)
{
tbSearchItemName.Text = "";
}
protectedvoidbtnSearch_Click(object sender, EventArgs
e)
{
BindGrid(true);
gvItem.Visible = true;
}
protectedvoidchkSelectAll_CheckedChanged(object sender, EventArgs
e)
{
CheckBox
chk;
foreach (GridViewRow rowItem in
gvItem.Rows)
{
chk =
(CheckBox)(rowItem.Cells[0].FindControl("selected"));
chk.Checked =
((CheckBox)sender).Checked;
}
}
////Bind the GridView to with the Database returned records
privatevoidBindGrid(bool Reload)
{
string
functionCode =
"";
//determine user access rights and show or hide edit
button
DataSet userAccessRights =
vrmdb.Get_OS_Permission(SessionHandler.UserLogin);
if
(userAccessRights.Tables[0].Rows.Count >
0)
{
functionCode =
userAccessRights.Tables[0].Rows[0][0].ToString();
if
(functionCode.Equals(generalconstant.VRM_VIEW_VML_ALL))
{
gvItem.Columns[GVEDITBTN].Visible =
false;
}
}
DataTable
dtItemsRecords = null;
if
(Reload)
{
//Get from db and bind to
datagrid
dtItemsRecords = vrmdb.GET_ItemsRecordss(tbSearchItemName.Text,
SessionHandler.UserLogin,
functionCode).Tables[0];
ViewState[viewStateGVName] =
dtItemsRecords;
}
else
{
//retrieve the ViewState object datatable from previous
retrieval
dtItemsRecords = ViewState[viewStateGVName] as
DataTable;
}
dtItemsRecords.DefaultView.Sort = ViewState[this.ToString()
+
"_SortExpression"].ToString() + " "
+
ViewState[this.ToString() + "_SortDirection"].ToString();
if
(dtItemsRecords !=
null)
{
if (dtItemsRecords.Rows.Count >
0)
{
gvItem.Columns[GVCHKBOX].Visible =
true;
gvItem.DataSource =
ViewState[viewStateGVName];
gvItem.AllowSorting =
true;
gvItem.DataBind();
}
else
{
dtItemsRecords.Rows.Add(dtItemsRecords.NewRow());
ViewState[viewStateGVName] =
dtItemsRecords;
gvItem.AllowSorting =
false;
gvItem.DataSource =
ViewState[viewStateGVName];
gvItem.DataBind();
//hide the checkbox and edit
columns
gvItem.Columns[GVCHKBOX].Visible =
false;
gvItem.Columns[GVEDITBTN].Visible = false;
int TotalColumns =
gvItem.Rows[0].Cells.Count;
gvItem.Rows[0].Cells.Clear();
gvItem.Rows[0].Cells.Add(new
TableCell());
ggvItem.Rows[0].Cells[0].ColumnSpan =
TotalColumns;
gvItem.Rows[0].Cells[0].Text = "No Record Found";
}
}
}
}
}
When I debug it there is error indicating:
com.os.database.os_database does not contain a definition for GET_ItemsRecords and no extension method "GET_ItemsRecords" accepting a first argument of type "com.os.database.os_database" can be found.(Are you missing a using directive or an assembly reference?
Thanks. Ur help is deepy appreciated by me.
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Krishna GaradRank #191 · 12.8K reputationPosted Jan 23, 2011, 8:58 PM EST
Krishna GaradRank #191 · 12.8K reputationPosted Jan 23, 2011, 8:58 PM EST
Becky Bloomwood110 reputationPosted Jan 25, 2011, 2:46 AM EST
public DataSet Get_ItemRecords(string templateName)
{
SqlCommand cmd_ItemList = new SqlCommand();
cmd_ItemList .CommandText = "[OS].[Get_ItemRecords]";
cmd_ItemList.CommandType = CommandType.StoredProcedure;
cmd_ItemList.Parameters.Clear();
SqlParameter sqlParaItemName = new SqlParameter("@itemName", SqlDbType.VarChar, 50);
sqlParaItemName.Value = itemName;
cmd_ItemList.Parameters.Add(sqlParaItemName);
DataSet ds_ItemList = getDataSet(cmd_ItemList);
return ds_ItemList;
}
Thks:)