Error 6002: The table/view 'Customer' does not have a primary key defined. The key has been inferred and the definition was created as a read-onte

0

System.Data.SqlClient.SqlException HResult=0x80131904 Message=Unclosed quotation mark after the character string '1398/11/09'. Incorrect syntax near '1398/11/09'.

Severity Code Description Project File Line Suppression State Suppression State Warning Error 6002: The table/view 'foroosh.dbo.Vw_Customer' does not have a primary key defined. The key has been inferred and the definition was created as a read-only table/view.
I am practicing on an accounting program that has encountered a problem. I created my own database build table and now I want to add datagrid and cascade data to my table but when I run the program it shows me the above error.How to solve this problem?

public partial class win_customer : Window
{
    public win_customer()
    {
        InitializeComponent();
    }


    forooshEntities database = new forooshEntities();

    private void Rectangle_MouseDown(object sender, MouseButtonEventArgs e)
    {
        this.DragMove();
    }

    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
        //var query = from U in database.Vw_Users select U;
        //var user = query.ToList();
        //dataGrid_user.ItemsSource = user;
        ShowUserInfo(SearchStatement);


    }
    private void ShowUserInfo(Func<string>SearchStringForUsers)
    {
        var query = database.Database.SqlQuery<Vw_Customer>("Select * From Vw_Customer where 1=1" + SearchStringForUsers());
        var u = query.ToList();
        dataGrid_customer.ItemsSource = u;
    }
    private string SearchStatement()
    {
        string searchstring = "and StartDate Between '" + string.Format("{0:yyyy/MM/dd}", Convert.ToDateTime(calendar_az.Text)) + "'And'" + string.Format("{0:yyyy/MM/dd}", Convert.ToDateTime(calendar_ta.Text));
        if (txt_name.Text != "")
        {
            searchstring += "and CustomerName Like '%" + txt_name.Text.Trim() + "%'";
        }
        if (txt_address.Text != "")
        {
            searchstring += "and CustomerAddress Like '%" + txt_address.Text.Trim() + "%'";
        }

        return searchstring;
    }
    private void image_search_MouseDown(object sender, MouseButtonEventArgs e)
    {
        ShowUserInfo(SearchStatement);
    }

    private void image_Close_MouseDown(object sender, MouseButtonEventArgs e)
    {
        this.Close();
    }


}

}

sql-server
wpf
view
syntax
tableview
asked on Stack Overflow Jan 29, 2020 by rezaftvt

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0