2016-04-11 12 views
-4

Programımı her çalıştırdığımda ve veritabanıma bir şey eklemeye başladığımda, bu hatayı yukarıda aldığımdan .Below benim kodumdur."NullReferenceException işe yaramadı" hatası alıyor

Cmd = new SqlCommand 
(@"INSERT INTO FileArchive (FFile, FTitle, FDesc, FIssuer, FType, FFileName,FDatePassed, FDatestored, FStoredby, SBID) 
    VALUES 
    ((SELECT * FROM Openrowset(BULK '" + txtFile.Text + "', SINGLE_BLOB) AS FFile),'" + txtTitle.Text + "', '" + txtDesc.Text + @"', 
    '" + txtIssuer.Text + "', '" + cbFileType.SelectedValue.ToString() + "', '" + txtFile.Text + "', '" + dtpDateP.Value.ToShortDateString() + @"', 
    '" + DateTime.Now.Date.ToShortDateString() + "', '" + sbsName.Text + @"', 
    (SELECT SBID from SBStaff where SBStaff.SBUser = '" + txtun.Text + "' and SBStaff.SBPass = '" + txtpw.Text + "'))", Con); 
+0

Toplam kodu ve toplam hata mesajını yapıştırmanız gerekiyor – TheGameiswar

cevap

0

Hata ayıklamayı öğrenin, sonra bu satırda bir kesme noktası belirleyin. Ara verdiğinizde, başvurulan tüm nesneleri inceleyin - bunlardan biri boştur. Girdiyi onaylayarak bu hatayı "koruyun".

Tamamen ayrı bir notta - SQL enjeksiyonunu okuyun.

İlgili konular