سلام عليكم ..
أوجه مشكلة.. الآن بعد تم الأتصال بعد داتا بيس و تأكد من الرقم الذي أدخله المستخدم صحيح.. أريد أن أضيف if statment جديدة لتتأكد من صلاحية بطاقته أن كان فيه ما يكفي ليغطي المرور أو لا.. لكل لا أعرف كيف يتم الأمر .. جننت.. هل من أحد يستطيع مساعدتي..
try { string hasdata; SqlConnection myconnection = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\football.mdf;Integrated Security=True;User Instance=True");
SqlCommand myCommand = new SqlCommand("Select 'CardSerialN','cardamount' from card Where CardSerialN='" + TextBox1.Text + "'and cardamount='" + DropDownList1.SelectedValue + "'", myconnection);
myCommand.Connection.Open();
hasdata = (string)myCommand.ExecuteScalar();
myCommand.Connection.Dispose();
if (hasdata == "CardSerialN") {
if (DropDownList1.SelectedValue>= "cardamount")
{Response.Write("Amont less"); }
}
else
{
Response.Write("data not exsit"); }
}
catch (Exception ex) {
Response.Write("Error:" + ex.Message);
}قمت بفتح جهة أتصال جديدة عبر هذا الكود
try
{
string hasdata;
string Amount;
SqlConnection myconnection = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\football.mdf;Integrated Security=True;User Instance=True");
SqlCommand myCommand = new SqlCommand("Select 'CardSerialN','cardamount' from card Where CardSerialN='" + TextBox1.Text + "'", myconnection);
SqlCommand myAmmount = new SqlCommand("Select 'cardamount' from card Where cardamount='" + DropDownList1.SelectedValue + "'", myconnection);
myCommand.Connection.Open();
myAmmount.Connection.Open();
hasdata = (string)myCommand.ExecuteScalar();
Amount = (string)myAmmount.ExecuteScalar();
myCommand.Connection.Dispose();
myAmmount.Connection.Dispose();
if (hasdata == "CardSerialN")
{
if (DropDownList1.SelectedValue>= "cardamount") {Response.Write("Amont less"); }
}
else
{
Response.Write("data not exsit");
}
}
catch (Exception ex)
{
Response.Write("Error:" + ex.Message);
}
{
Response.Write("Error:" + ex.Message);
}
}اذا أضيف أكبر من < تظهر لي مشكلة تقول
CS0019: Operator '>=' cannot be applied to operands of type 'string' and 'string'
تعبت و مستعجل جداً على تصليح هذا الكود من يتمكن في الموضوع لا يبخل علي لطفاً..
رحمه والدكم
رفعت الملف لكم المشكلة بصفحة reservation.aspx