Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. adding new data over ProcessLayer

adding new data over ProcessLayer

Scheduled Pinned Locked Moved C#
databasehelp
14 Posts 2 Posters 5 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Hiren solanki

    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 Like

    cmmd.Parameters.AddWithValue("@yetkili1",fir.yetkili1);

    Regards, Hiren. Microsoft Dynamics CRM

    My Recent Article: - Way to know which control have raised PostBack[^]

    E Offline
    E Offline
    Erdinc27
    wrote on last edited by
    #5

    i tried as u suggested but still nothing..it gives the same error..what else can be reason for that error ?

    vemedya.com

    H 1 Reply Last reply
    0
    • E Erdinc27

      i tried as u suggested but still nothing..it gives the same error..what else can be reason for that error ?

      vemedya.com

      H Offline
      H Offline
      Hiren solanki
      wrote on last edited by
      #6

      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[^]

      E 1 Reply Last reply
      0
      • H Hiren solanki

        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[^]

        E Offline
        E Offline
        Erdinc27
        wrote on last edited by
        #7

        again me..i added the code u said but still no magic :) u have any other suggesstion ?

        vemedya.com

        H 1 Reply Last reply
        0
        • E Erdinc27

          again me..i added the code u said but still no magic :) u have any other suggesstion ?

          vemedya.com

          H Offline
          H Offline
          Hiren solanki
          wrote on last edited by
          #8

          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[^]

          E 1 Reply Last reply
          0
          • H Hiren solanki

            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[^]

            E Offline
            E Offline
            Erdinc27
            wrote on last edited by
            #9

            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

            vemedya.com

            H 1 Reply Last reply
            0
            • E Erdinc27

              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

              vemedya.com

              H Offline
              H Offline
              Hiren solanki
              wrote on last edited by
              #10

              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[^]

              E 1 Reply Last reply
              0
              • H Hiren solanki

                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[^]

                E Offline
                E Offline
                Erdinc27
                wrote on last edited by
                #11

                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

                vemedya.com

                E 1 Reply Last reply
                0
                • E Erdinc27

                  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

                  vemedya.com

                  E Offline
                  E Offline
                  Erdinc27
                  wrote on last edited by
                  #12

                  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 ?

                  vemedya.com

                  H 1 Reply Last reply
                  0
                  • E Erdinc27

                    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 ?

                    vemedya.com

                    H Offline
                    H Offline
                    Hiren solanki
                    wrote on last edited by
                    #13

                    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 event btnEkle_Click you have called h.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[^]

                    E 1 Reply Last reply
                    0
                    • H Hiren solanki

                      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 event btnEkle_Click you have called h.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[^]

                      E Offline
                      E Offline
                      Erdinc27
                      wrote on last edited by
                      #14

                      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

                      vemedya.com

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups