i am getting this error this my c# code
Collapse | Copy Code
string Patient_name = NameTxtBx.Text, Export_TO = ToTxtBx0.Text;
int PatNoVal;
PatNoVal = Convert.ToInt32(PatNo.Text);
PatNoVal = int.Parse(PatNo.Text);
decimal PatID = decimal.Parse(PatID_NO.Text);
try
{
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "usp_NEW_TRANSACTIONS";
cmd.Parameters.AddWithValue("@Patient", Patient_name);
cmd.Parameters.AddWithValue("@E_TO", Export_TO);
cmd.Parameters.AddWithValue("@R_type", DropDownList1.SelectedItem.Text);
cmd.Parameters.AddWithValue("@User_name", Label1.Text = Session["name"].ToString());
cmd.Parameters.AddWithValue("@ReportType", DropDownList2.SelectedItem.Text);
cmd.Parameters.AddWithValue("@Patient_no", PatNoVal);
cmd.Parameters.AddWithValue("@Patient_ID_NO", PatID);
cmd.Parameters.Add("@ReturnIDcount", SqlDbType.NVarChar, 50);
cmd.Parameters["@ReturnIDcount"].Direction = ParameterDirection.Output;
cmd.Connection = con;
cmd.ExecuteNonQuery();
con.Close();
//Print("Your ID is : " + cmd.Parameters["@ReturnIDcount"].Value.ToString());
TextBox2.Text = cmd.Parameters["@ReturnIDcount"].Value.ToString();
ClientScriptManager cs = Page.ClientScript;
cs.RegisterStartupScript(this.GetType(), "IDCount", "alert(" + cmd.Parameters["@ReturnIDcount"].Value.ToString() + "');", true);
}
catch (Exception ex)
{
Message("Block 3: Error\nThe Reported fault is:\n" + ex.Message, this);
}
this is my stored procedure ..
Collapse | Copy Code
ALTER PROCEDURE [dbo].[usp_NEW_TRANSACTIONS]
(
@Patient nvarchar(50),
@E_TO nvarchar(50),
@R_type nvarchar(50),
@User_name nvarchar(50),
@ReportType nvarchar(50),
@Patient_no int,
@Patient_ID_NO numeric(18,0),
@ReturnIDcount nvarchar(max) output
)
AS
BEGIN
declare @idcount numeric(18,0)
declare @tempid numeric(18,0)
set @tempid = 0;
declare @idcnt numeric(18,0)
select @idcnt =isnull( max(idcount),0) from Transactions where year(R_date)=year(getdate())
if (@idcnt =0)
set @tempid=1
else
set @tempid = @idcnt +1
--sign at end : set @ReturnIDcount = '301A' + cast( @idcount as nvarchar)
INSERT INTO dbo.Transactions (Patient,E_TO,R_date,R_from,User_name,report_type,Patient_no,Patient_ID_NO,idcount,ReturnIDcount)values (@Patient,@E_TO,getdate(),@R_type,@User_name,@ReportType,@Patient_no,@Patient_ID_NO,@tempid,@ReturnIDcount)
select @idcount =isnull( max(idcount),0) from Transactions where year(R_date)=year(getdate())
set @ReturnIDcount = '41/3/' + cast( @idcount as nvarchar)
return @ReturnIDcount
END