This question is locked. New answers and comments are not allowed.
I want to add a new entity to table which has relation to another table.I write an sql procedure to do this.But there is a coulum ın the table that in nvarchar.My stored procedure includes this.
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sp_ins_Object_DIS] (@object_ID UNIQUEIDENTIFIER ,@category INTEGER , @country INTEGER , @domain INTEGER , @extra INTEGER , @kind INTEGER , @marking NVARCHAR , @specific INTEGER , @sub_category INTEGER) AS INSERT INTO [Objects_DIS] ( [object_ID] , [category] , [country] , [domain] , [extra] , [kind] , [marking] , [specific], [sub_category] ) VALUES ( @object_ID , @category , @country , @domain , @extra , @kind , @marking , @specific , @sub_category)
I am calling this procedure from code by sending parameter but there is no equivalent for nvarchar in C#.ı want to sent textbox string value.It gives error.Please help.
if (!m_scope.Transaction.IsActive)
{
m_scope.Transaction.Begin();
}
Platform selectedPlatform = (Platform)m_lbx_SAMPlatform.SelectedItem;
string query = "SELECT * FROM ObjectsDISExtent AS c WHERE c.platform = $1";
IQueryResult result = m_scope.GetOqlQuery(query).Execute(selectedPlatform);
ArrayList resultSet = result.ToList();
if (resultSet.Count > 0)//to change existing variables
{
ObjectsDIS platformDIS = (ObjectsDIS)resultSet[0];
platformDIS.Kind = m_cmbbx_SamKind.SelectedIndex;
platformDIS.Domain = m_cmbbx_SamDomain.SelectedIndex;
platformDIS.Country = Int16.Parse(m_txtbx_SamCountry.Text);
platformDIS.Category = Int16.Parse(m_txtbx_SamCategory.Text);
platformDIS.Specific = Int16.Parse(m_txtbx_SAMSpecific.Text);
platformDIS.SubCategory = Int16.Parse(m_txtbx_SAMSubCategory.Text);
platformDIS.Extra = Int16.Parse(m_txtbx_SamExtra.Text);
platformDIS.Marking = m_txtbx_SAMMarking.Text;
}
else//insert new if there is no entity for selected platform.This gives error
{
IQuery newquery = m_scope.GetSqlQuery("sp_ins_Object_DIS ?,?,?,?,?,?,?,?,?",
null,
"GUID object_ID, INTEGER category, INTEGER country, INTEGER domain ,INTEGER extra, INTEGER kind, NVARCHAR marking,INTEGER specific,INTEGER sub_category");
IQueryResult newa = newquery.Execute(new object[] { selectedPlatform.Id, Int16.Parse(m_txtbx_SamCategory.Text), Int16.Parse(m_txtbx_SamCountry.Text), m_cmbbx_SamDomain.SelectedIndex, Int16.Parse(m_txtbx_SamExtra.Text), m_cmbbx_SamKind.SelectedIndex, m_txtbx_SAMMarking.Text, Int16.Parse(m_txtbx_SAMSpecific.Text), Int16.Parse(m_txtbx_SAMSubCategory.Text) });
int newcount = newa.Count;
}
m_scope.Transaction.Commit();
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sp_ins_Object_DIS] (@object_ID UNIQUEIDENTIFIER ,@category INTEGER , @country INTEGER , @domain INTEGER , @extra INTEGER , @kind INTEGER , @marking NVARCHAR , @specific INTEGER , @sub_category INTEGER) AS INSERT INTO [Objects_DIS] ( [object_ID] , [category] , [country] , [domain] , [extra] , [kind] , [marking] , [specific], [sub_category] ) VALUES ( @object_ID , @category , @country , @domain , @extra , @kind , @marking , @specific , @sub_category)
I am calling this procedure from code by sending parameter but there is no equivalent for nvarchar in C#.ı want to sent textbox string value.It gives error.Please help.
if (!m_scope.Transaction.IsActive)
{
m_scope.Transaction.Begin();
}
Platform selectedPlatform = (Platform)m_lbx_SAMPlatform.SelectedItem;
string query = "SELECT * FROM ObjectsDISExtent AS c WHERE c.platform = $1";
IQueryResult result = m_scope.GetOqlQuery(query).Execute(selectedPlatform);
ArrayList resultSet = result.ToList();
if (resultSet.Count > 0)//to change existing variables
{
ObjectsDIS platformDIS = (ObjectsDIS)resultSet[0];
platformDIS.Kind = m_cmbbx_SamKind.SelectedIndex;
platformDIS.Domain = m_cmbbx_SamDomain.SelectedIndex;
platformDIS.Country = Int16.Parse(m_txtbx_SamCountry.Text);
platformDIS.Category = Int16.Parse(m_txtbx_SamCategory.Text);
platformDIS.Specific = Int16.Parse(m_txtbx_SAMSpecific.Text);
platformDIS.SubCategory = Int16.Parse(m_txtbx_SAMSubCategory.Text);
platformDIS.Extra = Int16.Parse(m_txtbx_SamExtra.Text);
platformDIS.Marking = m_txtbx_SAMMarking.Text;
}
else//insert new if there is no entity for selected platform.This gives error
{
IQuery newquery = m_scope.GetSqlQuery("sp_ins_Object_DIS ?,?,?,?,?,?,?,?,?",
null,
"GUID object_ID, INTEGER category, INTEGER country, INTEGER domain ,INTEGER extra, INTEGER kind, NVARCHAR marking,INTEGER specific,INTEGER sub_category");
IQueryResult newa = newquery.Execute(new object[] { selectedPlatform.Id, Int16.Parse(m_txtbx_SamCategory.Text), Int16.Parse(m_txtbx_SamCountry.Text), m_cmbbx_SamDomain.SelectedIndex, Int16.Parse(m_txtbx_SamExtra.Text), m_cmbbx_SamKind.SelectedIndex, m_txtbx_SAMMarking.Text, Int16.Parse(m_txtbx_SAMSpecific.Text), Int16.Parse(m_txtbx_SAMSubCategory.Text) });
int newcount = newa.Count;
}
m_scope.Transaction.Commit();