ERROR FOUND" Column 'SerialNo' does not belong to table Table. AND IN CORRECT SYNATXX NEAR ';'
ALTER PROCEDURE [dbo].[prctblSalesInvoiceView]
(
@WhereCondition nvarchar(4000)
)
as
--prctblPurchaseInvoiceView ''
declare @SQLQuery nvarchar(4000);
BEGIN
set @SQLQuery='
select
iSerialNo
,iSalesID
,iAccID
,vAccName as ''CustomerName''
,vBillNo as ''BillNo''
,convert(varchar,dInvoiceDate,106) as ''InvoiceDate''
,vOldNew as OldNew
,deTotAmount as TotalAmount
,deRecAmount as RecAmount
,deBalAmount as BalAmount
,deMakChargesTotal as MakChargesTotal
from tblSales
'
+@WhereCondition
exec sp_executesql @SQLQuery
END
private void fnInvoiceDetailsrView(string searchvalue)
{
try
{
DataSet ds = new DataSet();
ds.Tables.Clear();
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = new SqlCommand("prctblSalesInvoiceView", ClsConnect.conSql);
sda.SelectCommand.CommandType = CommandType.StoredProcedure;
sda.SelectCommand.Parameters.AddWithValue("@WhereCondition", searchvalue);
string s = ClsConnect.conSql.State.ToString();
if (s == "Open")
{
ClsConnect.conSql.Close();
}
ClsConnect.conSql.Open();
sda.Fill(ds);
ClsConnect.conSql.Close();
if (ds.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
ds.Tables[0].Rows[i]["SerialNo"] = i + 1;
}
dgvBillSearch.DataSource = ds.Tables[0];
dgvBillSearch.Columns[0].Width = 60;
dgvBillSearch.Columns[1].Visible = false;
dgvBillSearch.Columns[2].Visible = false;
dgvBillSearch.Columns[3].Width = 114;
dgvBillSearch.Columns[4].Width = 75;
dgvBillSearch.Columns[5].Width = 75;
dgvBillSearch.Columns[6].Width = 75;
dgvBillSearch.Columns[7].Width = 75;
dgvBillSearch.Columns[8].Width = 75;
dgvBillSearch.Columns[9].Width = 75;
}
}
catch (Exception ex)
{
fnInvoiceDetailsrView("");
// MessageBox.Show(ex.Message);
}
txtCustCodeName.Focus();
}