adding new data over ProcessLayer
-
erdinc27 wrote:
cmmd.Parameters.AddWithValue("@yetkili1", System.Data.SqlDbType.NVarChar).Value = fir.yetkili1;
You have used blockquoted way to add parameter with value. But AddWithValue having format of
AddWithValue(string Parametername,object value)
Your statement must generate compile time error I think, Use Likecmmd.Parameters.AddWithValue("@yetkili1",fir.yetkili1);
Regards, Hiren. Microsoft Dynamics CRM
My Recent Article: - Way to know which control have raised PostBack[^]
i tried as u suggested but still nothing..it gives the same error..what else can be reason for that error ?
-
i tried as u suggested but still nothing..it gives the same error..what else can be reason for that error ?
Okey As you have done all suggested things. Now Add one thing and see the magic. After intializing command object which is cmmd, Put a line like.
cmmd.CommandType = CommandType.StoredProcedure
Regards, Hiren. Microsoft Dynamics CRM
My Recent Article: - Way to know which control have raised PostBack[^]
-
Okey As you have done all suggested things. Now Add one thing and see the magic. After intializing command object which is cmmd, Put a line like.
cmmd.CommandType = CommandType.StoredProcedure
Regards, Hiren. Microsoft Dynamics CRM
My Recent Article: - Way to know which control have raised PostBack[^]
again me..i added the code u said but still no magic :) u have any other suggesstion ?
-
again me..i added the code u said but still no magic :) u have any other suggesstion ?
I think now you might have some problem with
InsertData()
Method. Can you show us that method,So that we can have better Idea of a whole scenario.Regards, Hiren. Microsoft Dynamics CRM
My Recent Article: - Way to know which control have raised PostBack[^]
-
I think now you might have some problem with
InsertData()
Method. Can you show us that method,So that we can have better Idea of a whole scenario.Regards, Hiren. Microsoft Dynamics CRM
My Recent Article: - Way to know which control have raised PostBack[^]
here is my InsertData()method
public SqlCommand InsertData()
{
cmd = new SqlCommand("sp_AddDatas", con);
cmd.CommandType = CommandType.StoredProcedure;
return cmd;
}and here is the sp_AddDatas
ALTER procedure [dbo].[sp_AddDatas]
(
@firmanin_adi nvarchar(70),
@yetkili1 nvarchar(30),
@gsm_num1 nvarchar(20),
@e_mail1 nvarchar(30),
@yetkili2 nvarchar(30),
@gsm_num2 nvarchar(20),
@e_mail2 nvarchar(30),
@yetkili3 nvarchar(30),
@gsm_num3 nvarchar(20),
@e_mail3 nvarchar(30),
@tlfn1 nvarchar(20),
@tlfn2 nvarchar(20),
@tlfn3 nvarchar(20),
@tlfn4 nvarchar(20),
@tlfn5 nvarchar(20)
)
as
BEGIN
Insert Into Firmalar(firma_adi,yetkili_ad1,Gsm1,email1,yetkili_ad2,Gsm2,Email2,yetkili_ad3,Gsm3,Email3,Telefon1,Telefon2,Telefon3,Telefon4,Telefon5)Values (@firmanin_adi, @yetkili1,@gsm_num1,@e_mail1,@yetkili2,@gsm_num2,@e_mail2, @yetkili3,@gsm_num3,@e_mail3,@tlfn1,@tlfn2,@tlfn3,@tlfn4,@tlfn5)
END -
here is my InsertData()method
public SqlCommand InsertData()
{
cmd = new SqlCommand("sp_AddDatas", con);
cmd.CommandType = CommandType.StoredProcedure;
return cmd;
}and here is the sp_AddDatas
ALTER procedure [dbo].[sp_AddDatas]
(
@firmanin_adi nvarchar(70),
@yetkili1 nvarchar(30),
@gsm_num1 nvarchar(20),
@e_mail1 nvarchar(30),
@yetkili2 nvarchar(30),
@gsm_num2 nvarchar(20),
@e_mail2 nvarchar(30),
@yetkili3 nvarchar(30),
@gsm_num3 nvarchar(20),
@e_mail3 nvarchar(30),
@tlfn1 nvarchar(20),
@tlfn2 nvarchar(20),
@tlfn3 nvarchar(20),
@tlfn4 nvarchar(20),
@tlfn5 nvarchar(20)
)
as
BEGIN
Insert Into Firmalar(firma_adi,yetkili_ad1,Gsm1,email1,yetkili_ad2,Gsm2,Email2,yetkili_ad3,Gsm3,Email3,Telefon1,Telefon2,Telefon3,Telefon4,Telefon5)Values (@firmanin_adi, @yetkili1,@gsm_num1,@e_mail1,@yetkili2,@gsm_num2,@e_mail2, @yetkili3,@gsm_num3,@e_mail3,@tlfn1,@tlfn2,@tlfn3,@tlfn4,@tlfn5)
ENDNow I don't have any clue but see my answer I have given for THIS[^], and try to give parameters value like that way. And also show us a full error statement to be further analyzing.
Regards, Hiren. Microsoft Dynamics CRM
My Recent Article: - Way to know which control have raised PostBack[^]
-
Now I don't have any clue but see my answer I have given for THIS[^], and try to give parameters value like that way. And also show us a full error statement to be further analyzing.
Regards, Hiren. Microsoft Dynamics CRM
My Recent Article: - Way to know which control have raised PostBack[^]
hi again..i tried to add values like in the link u sent at that time it given error like "an SqlParameter with parameter name '@firmanin_adi' is not contained by this SqlParameterCollection" in my process layer
-
hi again..i tried to add values like in the link u sent at that time it given error like "an SqlParameter with parameter name '@firmanin_adi' is not contained by this SqlParameterCollection" in my process layer
hi friend it adds the datas now i changed something more after u offered..thanks for help and one more question; is it too redicilous way to write a method which gets 15 parameters in my process layer and them to call it in my form inside and to assign the parameters here ?
-
hi friend it adds the datas now i changed something more after u offered..thanks for help and one more question; is it too redicilous way to write a method which gets 15 parameters in my process layer and them to call it in my form inside and to assign the parameters here ?
That's okey the way you are processing. But Why you have kept a seperate method for
InsertData()
You should Initialize command there itself. No need for extra garbage. Wrap thing in a function that can be reusable or having something meaning. You got your problem solved now, I have also found why you were getting error let me tell you if you have found the same or different. In your eventbtnEkle_Click
you have calledh.InsertFirm(firma);
directly without setting value for each property, and after finishing a whole operation you are assigning value, I think you're very much newbie with OOPS. try to read some books around will give you better idea on this.Regards, Hiren. Microsoft Dynamics CRM
My Recent Article: - Way to know which control have raised PostBack[^]
-
That's okey the way you are processing. But Why you have kept a seperate method for
InsertData()
You should Initialize command there itself. No need for extra garbage. Wrap thing in a function that can be reusable or having something meaning. You got your problem solved now, I have also found why you were getting error let me tell you if you have found the same or different. In your eventbtnEkle_Click
you have calledh.InsertFirm(firma);
directly without setting value for each property, and after finishing a whole operation you are assigning value, I think you're very much newbie with OOPS. try to read some books around will give you better idea on this.Regards, Hiren. Microsoft Dynamics CRM
My Recent Article: - Way to know which control have raised PostBack[^]
yeah i am new about it really and try to learn it..i hope it doesnt take much time to improve my skills :) thanks for your help again