Lanka Developers Community

    Lanka Developers

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Shop

    MySQL DB Connection එක මෙහෙම දැම්මහම errors,warnings මුකුත් එන්නෙ නන් නෑ...ඒත් DB එකට data insert වෙන් නෑ..හේතුව මොකක්ද?.

    Back-End Development
    c sharp mysql asp.net
    2
    17
    2371
    Loading More Posts
    • 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.
    • Dinuwan Kalubowila
      Dinuwan Kalubowila last edited by

      using MySql.Data.MySqlClient;
      using System.Data;

      public partial class index : System.Web.UI.Page
      {

          public String connectionString = @"server=localhost;port=3306;user id=root;database=Product;persistsecurityinfo=True;password=ThirtyFirst9731@;";
          protected void Page_Load(object sender, EventArgs e)
          {
          
      
              if (!IsPostBack)
              {
                  clear();
              }
      
          }
      
      
          protected void btnInsert_Click(object sender, EventArgs e)
          {
              MySqlConnection mySqlCon = new MySqlConnection(connectionString);
      
              try
              {
                  using (mySqlCon)
                  {
                      mySqlCon.Open();
                   
                      MySqlCommand mySqlCmd = new MySqlCommand("Proc_Store_Products", mySqlCon);
                      mySqlCmd.CommandType = CommandType.StoredProcedure;
                      mySqlCmd.Parameters.AddWithValue("_productId", Convert.ToInt32(hfProductID.Value == "" ? "0" : hfProductID.Value));
                      mySqlCmd.Parameters.AddWithValue("_productCode", txtproductCode.Text.Trim());
                      mySqlCmd.Parameters.AddWithValue("_productName", txtproductName.Text.Trim());
                      mySqlCmd.Parameters.AddWithValue("_price", Convert.ToDecimal(txtprice.Text.Trim()));
                      mySqlCmd.Parameters.AddWithValue("_description", txtdescription.Text.Trim());
      
                      mySqlCmd.ExecuteNonQuery();
      
                      clear();
                      lblSuccessMsg.Text = "Submitted Successfully";
                  }
      
      
              }
              catch (Exception ex)
              {
                  lblErrorMsg.Text = ex.Message;
              }
      
      
      
      
          }
      

      }

      1 Reply Last reply Reply Quote 0
      • Nubelle
        Nubelle Web Development last edited by

        Proc_Store_Products kiyane insert query ekada mchan , web.config eke connection string eka hadauwda

        1 Reply Last reply Reply Quote 0
        • Dinuwan Kalubowila
          Dinuwan Kalubowila last edited by

          ow eka thama stored procedure eka....web config eke nan nemi haduwe connection eka nan...eka tring variable ekakkta gatta

          1 Reply Last reply Reply Quote 0
          • Nubelle
            Nubelle Web Development last edited by

            web config eke define krala balapn mchan
            <add name="any name" connectionString="server=localhost; User Id=root; password=example; Persist Security Info=True; database=dbname; Max Pool Size=5000; Connection Timeout=200" providerName="MySql.Data.MySqlClient"/>

            1 Reply Last reply Reply Quote 0
            • Dinuwan Kalubowila
              Dinuwan Kalubowila last edited by

              elama!!! thanks mn blnnm

              Nubelle 1 Reply Last reply Reply Quote 0
              • Nubelle
                Nubelle Web Development last edited by

                db cls eka wenam hadana , wenama cs ekak tiygagena balan

                public MySqlConnection DBConnect()
                {
                try
                {
                MySqlConnection con = new MySqlConnection();
                con.ConnectionString = ConfigurationManager.ConnectionStrings["any name"].ConnectionString;
                return con;
                }
                catch (MySqlException mye)
                {
                err.createErrorLog(mye.Message, mye.Source, "MySQL error");
                return null;
                }
                catch (Exception e)
                {
                err.createErrorLog(e.Message, e.Source, "Data Connection error");
                return null;
                }
                }

                1 Reply Last reply Reply Quote 0
                • Nubelle
                  Nubelle Web Development @Dinuwan Kalubowila last edited by

                  @Dinuwan-Kalubowila elzzzz balala kiyapn

                  1 Reply Last reply Reply Quote 0
                  • Dinuwan Kalubowila
                    Dinuwan Kalubowila last edited by

                    eth hariyan ne bn

                    Nubelle 1 Reply Last reply Reply Quote 0
                    • Nubelle
                      Nubelle Web Development @Dinuwan Kalubowila last edited by

                      @Dinuwan-Kalubowila sp eke aulk aththe mchan ehenam

                      1 Reply Last reply Reply Quote 0
                      • Dinuwan Kalubowila
                        Dinuwan Kalubowila last edited by

                        sp ekata normal workbench eke execute kalahama wada krnw bn...

                        1 Reply Last reply Reply Quote 0
                        • Nubelle
                          Nubelle Web Development last edited by

                          break point ekak dala podak run krala balapn

                          1 Reply Last reply Reply Quote 0
                          • Dinuwan Kalubowila
                            Dinuwan Kalubowila last edited by

                            mchn connect wenwa....mokada display wen tika wenwa...eth insert wen ne...asp.net wala form ekakin insert karaddi POST,GET methods denna onada?

                            1 Reply Last reply Reply Quote 0
                            • Nubelle
                              Nubelle Web Development last edited by

                              web forms neda gahuwe

                              1 Reply Last reply Reply Quote 0
                              • Dinuwan Kalubowila
                                Dinuwan Kalubowila last edited by

                                <form id="Form1" reunt = "server" method="POST">
                                <asp:Button Text="Button Name" reunt="server" >
                                </form>

                                ASP walath me widiyata form tag eke method eka danna onada bn?

                                1 Reply Last reply Reply Quote 0
                                • Nubelle
                                  Nubelle Web Development last edited by

                                  reunt nawei mchan runat

                                  1 Reply Last reply Reply Quote 0
                                  • Dinuwan Kalubowila
                                    Dinuwan Kalubowila last edited by

                                    wade hti mchn.....button click enet eka watila nehe html eke..dan wada..

                                    Nubelle 1 Reply Last reply Reply Quote 0
                                    • Nubelle
                                      Nubelle Web Development @Dinuwan Kalubowila last edited by

                                      @Dinuwan-Kalubowila elzzz

                                      1 Reply Last reply Reply Quote 0
                                      • 1 / 1
                                      • First post
                                        Last post

                                      3
                                      Online

                                      3.7k
                                      Users

                                      1.3k
                                      Topics

                                      5.3k
                                      Posts

                                      • Privacy
                                      • Terms & Conditions
                                      • Donate

                                      © Copyrights and All right reserved Lanka Developers Community

                                      Powered by Axis Technologies (PVT) Ltd

                                      Made with in Sri Lanka

                                      | |