0

In my SQL select part i have column like this;

NVL(RISK_SASI(A.TEKLIF_NO1, A.TEKLIF_NO2, C.URUN_SIRA_NO, C.SIRA_NO, :S_DATE),0) AS RISK

And I adding dinamicly with a TextBox this S_DATE value.

string txtBoxText1 = ((TextBox)Page.FindControl("TextBox1")).Text;
if (txtBoxText1 != "")
dt_stb = DateTime.Parse(txtBoxText1);
myCommand.Parameters.AddWithValue(":S_TARIH_B", dt_stb);

BUT it didn't work for my SQL.

Here is mine full SQL;

SELECT A.HESAP_NO, A.TEKLIF_NO1 || '/' || A.TEKLIF_NO2 AS TEKLIF, A.MUS_K_ISIM AS MUSTERI, 
                    B.MARKA, C.SASI_NO, C.SASI_DURUM, D.TAS_MAR, NVL(RISK_SASI(A.TEKLIF_NO1, A.TEKLIF_NO2, C.URUN_SIRA_NO, C.SIRA_NO, :S_TARIH_B),0) AS RISK,
                    NVL(MV_SASI(A.TEKLIF_NO1, A.TEKLIF_NO2, C.SIRA_NO, C.URUN_SIRA_NO, :S_TARIH_B),0) AS MV,
                    MV_K(A.TEKLIF_NO1,A.TEKLIF_NO2, :S_TARIH_B) AS KV
                    FROM S_TEKLIF A,  S_URUN B, S_URUN_DETAY C, KOC_KTMAR_PR D
                    WHERE A.TEKLIF_NO1 || A.TEKLIF_NO2 = B.TEKLIF_NO1 || B.TEKLIF_NO2
                    AND A.TEKLIF_NO1 || A.TEKLIF_NO2 = C.TEKLIF_NO1 || C.TEKLIF_NO2
                    AND B.SIRA_NO = C.URUN_SIRA_NO
                    AND B.DISTRIBUTOR = D.DIST_KOD
                    AND B.MARKA = D.MARKA_KOD
                    AND B.URUN_KOD = D.TAS_KOD

How can i do that?

Best Regards, Soner

2
  • 1
    Dont know how oracles adonet interface works, but you can try using @S_TARIH_B instead of :S_TARIH_B both in addparameter and in the query. Commented Mar 25, 2011 at 8:45
  • 1
    @Johann its quite obvious from his traced query. Commented Mar 25, 2011 at 8:51

1 Answer 1

2

When using parameters with ORACLE, you'd have to use @ instead of :. I recently asked a question about how to make this generic in code. You might want to have a look at it: DbCommand and parameterized SQL, ORACLE vs SQL Server

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.