开发者

Update Statement not working [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifyi开发者_开发知识库ng this question so that it can be reopened, visit the help center. Closed 11 years ago.

So I have a SQL express server database. I have an inventory file. I have one statement to insert new records, and another one to update count in all records. The first one works fine, however I can not get the count to update. I wrapped each of those statement in there own try, catch and it does not catch. I am pretty lost here.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication8
{
class Program
{
    static void Main(string[] args)
    {
        string[] lines = System.IO.File.ReadAllLines(@"C:\out\b.txt");
        //System.Console.WriteLine("Contents of writeLines2.txt =:");
        int i = 0;
        foreach (string line in lines)
        {



                string sellername, sku, date1, quantity1, date2, asin, date3, date4, FNSKU;
                char[] tabs = { '\t' };
                string[] words = line.Split(tabs);

                sku = words[0];
                FNSKU = words[1];
                asin = words[2];
                quantity1 = words[5];
                Console.WriteLine("\t" + line);
                inventoryBLL u = new inventoryBLL();
                try
                {
                    u.AddToDatabase(sku, DateTime.Now, Convert.ToInt16(0), DateTime.Now, 0, asin, DateTime.Now, DateTime.Now, FNSKU);

                }
                catch
                { }
                try
                {
                    u.UpdateDatabase(sku, quantity1);

                }
                catch
                { }

                foreach (string s in words)
                {
                    System.Console.WriteLine(s);
                }


            ++i;

        }

        // Keep the console window open in debug mode.
        Console.WriteLine("Press any key to exit.");
        System.Console.ReadKey();
    }
}
 }

Here is the bll

 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using ConsoleApplication8.DataSet1TableAdapters;

 namespace ConsoleApplication8
 {
[System.ComponentModel.DataObject]
class inventoryBLL
{
    private AmazonSKUsTableAdapter _skuAdapter = null;
    protected AmazonSKUsTableAdapter Adatper
    {
        get
        {
            if (_skuAdapter == null)
                _skuAdapter = new AmazonSKUsTableAdapter();

            return _skuAdapter;
        }
    }

    [System.ComponentModel.DataObjectMethodAttribute
        (System.ComponentModel.DataObjectMethodType.Insert, false)]
    public void AddToDatabase(string sku, DateTime date, int quantity, DateTime date1, int quantity1, string asin, DateTime date2, DateTime date3, string FNSKU)
    {
        Adatper.AddToDatabase("A1B7M9EQGNCLQA", sku, date, quantity, date1, quantity1, asin, date2, date3, FNSKU);

    }

            [System.ComponentModel.DataObjectMethodAttribute
        (System.ComponentModel.DataObjectMethodType.Update, false)]
    public void UpdateDatabase(string sku, string quality)
    {
        Adatper.UpdateQuery(Convert.ToInt16(quality), sku);
    }
}

 }

Here is the query:

 UPDATE       AmazonSKUs
 SET                TotalQty = @TotalQty
 WHERE        (MerchantSKU = @Original_MerchantSKU); 


Why don't you try putting some output statements in your catch blocks. Odds are excellent that it's reporting the error; but without acting on the caught items, you're likely throwing away the issues it is reporting!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜