MySQL DB Connection එක මෙහෙම දැම්මහම errors,warnings මුකුත් එන්නෙ නන් නෑ...ඒත් DB එකට data insert වෙන් නෑ..හේතුව මොකක්ද?.
-
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; } }
}
-
Proc_Store_Products kiyane insert query ekada mchan , web.config eke connection string eka hadauwda
-
ow eka thama stored procedure eka....web config eke nan nemi haduwe connection eka nan...eka tring variable ekakkta gatta
-
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"/> -
elama!!! thanks mn blnnm
-
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;
}
} -
@Dinuwan-Kalubowila elzzzz balala kiyapn
-
eth hariyan ne bn
-
@Dinuwan-Kalubowila sp eke aulk aththe mchan ehenam
-
sp ekata normal workbench eke execute kalahama wada krnw bn...
-
break point ekak dala podak run krala balapn
-
mchn connect wenwa....mokada display wen tika wenwa...eth insert wen ne...asp.net wala form ekakin insert karaddi POST,GET methods denna onada?
-
web forms neda gahuwe
-
<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?
-
reunt nawei mchan runat
-
wade hti mchn.....button click enet eka watila nehe html eke..dan wada..
-
@Dinuwan-Kalubowila elzzz