C# Nesne Başvurusu Bir Nesnenin Örneğine Ayarlanmadı.
-
Yapmaya çalıştıgım şey mikro programından stokları opencarta aktarmak. Program başlıktaki hatayı veriyor.
Mikrodaki kodla opencarttaki kodu eşletirip opencarttaki idyi alıyorum.
// text mikrodaki koddan geliyor onda sıkıntı yok // Opencarttan mikrodan gönderdiğim kodla product_id leri çekiyorum MySqlCommand mysqlCommand = new MySqlCommand("SELECT product_id FROM `product` where model=@model", bag); mysqlCommand.Parameters.AddWithValue("@model", text); // product id string text2 = mysqlCommand.ExecuteScalar().ToString(); MySqlCommand mysqlCommand2 = new MySqlCommand("SELECT product_option_id FROM `product_option` where product_id=@product_id", bag); mysqlCommand2.Parameters.AddWithValue("@product_id", text2); // string text3 = mysqlCommand2.ExecuteScalar().ToString(); int say = (int)mysqlCommand2.ExecuteScalar(); if (say == 0)// Eğer option id yoksa { // ekleniyor MySqlCommand mysqlCommand6 = new MySqlCommand("INSERT INTO product_option (product_id,option_id,required) VALUES(@product_id,@option_id,@required)", bag); mysqlCommand6.Parameters.AddWithValue("@product_id", text2); mysqlCommand6.Parameters.AddWithValue("@option_id", 5); mysqlCommand6.Parameters.AddWithValue("@required", 1); mysqlCommand6.ExecuteNonQuery(); long id = mysqlCommand6.LastInsertedId; // son eklenen idyi alıyoruz text3 = Convert.ToString(id); } else { //varsa siliyoruz MySqlCommand mysqlCommand3 = new MySqlCommand("delete FROM `product_option_value` where product_id=@product_id", bag); mysqlCommand3.Parameters.AddWithValue("@product_id", text2); mysqlCommand3.ExecuteNonQuery(); string text3 = mysqlCommand2.ExecuteScalar().ToString(); // mysql 2 den geliiyor }şimdi araştırdığıma göre null deger olmuyormuş say 0 döndüğünde ben bu sorguyu çalıştırmam lazım ancak 0 geldiğinde program direk duruyor.
-
Hocam breakpoint atıp satır satır ilerleyebilirsin. Açıkcası buradan bir şey anlaşılmıyor.
-
ontedi bunu yazdı
Hocam breakpoint atıp satır satır ilerleyebilirsin. Açıkcası buradan bir şey anlaşılmıyor.
olay şu hocam say değişkeni sorgudan dönen satır sayısı veriyor o dönen değer 0 oldugunda program hata veriyor bunu nasıl aşabilirim :)
-
intsay = (int)mysqlCommand2.ExecuteScalar();bunustring say =mysqlCommand2.ExecuteScalar().toString();response.write(say);şeklinde değiştirip ekrana yazdırmayı denesene. Ama aşağıdaki if blogunu yoruma al.
ontedi tarafından 03/Haz/16 16:09 tarihinde düzenlenmiştir -
ontedi bunu yazdı
intsay = (int)mysqlCommand2.ExecuteScalar();bunustring say =mysqlCommand2.ExecuteScalar().toString();response.write(say);şeklinde değiştirip ekrana yazdırmayı denesene. Ama aşağıdaki if blogunu yoruma al.saolsın hocam çözdüm sorunu
