Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8820943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:43:56+00:00 2026-06-14T05:43:56+00:00

I’m working on a quote manager for my boss at work and I’m having

  • 0

I’m working on a quote manager for my boss at work and I’m having some issues. This is a WPF C# application and it’s the first time I’ve ever built anything that works with a SQL Server database. I’m currently having three issues.

Background:

When the user opens the application they’re greeted with a DataGrid, a new quote button and several other controls that I haven’t yet created. When they press the new quote button a new window pops up with a form that will have text boxes for things like Customer Name, quantity, etc. At the bottom of that form is a submit button, at which point the window will close and the information they added will be inserted into the DataGrid as a new row.

Problem One:

One of the fields in my database is called Open_Quote and it is supposed to be hold the date we received the order. This is handled programmatically and is what my first question involves. I’ll include all of the code at the bottom of this post, but when the user hits submit I receive the following error: “Conversion failed when converting date and/or time from character string.”

Problem Two:

In an attempt to test the rest of my code and go back later to fix the date issue, I commented that code out and tried running my program again. This time I get a different error: “Incorrect syntax around ‘newQuote.Qty’.”

Problem Three:

Again, commenting that code out in order to finally test the rest of my code, I received a third error: “string or binary data would be truncated. This process has been terminated.”

My hope is that there’s one piece of code that’s causing all three of these issues, but I could be completely off there. I’ve been pulling my hair out for over a day trying to figure this out. Anyway, here’s the code:

newQuote.xaml.cs:

    private void SubmitQuotebtn_Click(object sender, RoutedEventArgs e)
    {
        CustomerData newQuote = new CustomerData();

        int quantity;
        quantity = Convert.ToInt32(Qtytxt.Text);

        string theDate = System.DateTime.Today.Date.ToString("d");

        newQuote.OpenQuote = theDate;
        newQuote.CustomerName = CustNametxt.Text;
        newQuote.OEMName = OemNametxt.Text;
        newQuote.Qty = quantity;
        newQuote.QuoteNumber = QuoteNumtxt.Text;
        newQuote.FdNumber = FabDrawingNumtxt.Text;
        newQuote.RfqNumber = RfqNumtxt.Text;
        newQuote.RevNumber = RevNumtxt.Text;

        try
        {
            string insertConString = Sqtm.Properties.Settings.Default.SqtmDbConnectionString;

            using (SqlConnection insertConnection = new SqlConnection(insertConString))
            {
                insertConnection.Open();

                SqlCommand cmd = new SqlCommand("INSERT INTO General_Info(Open_Quote, Customer_Name, OEM_Name, Qty, Quote_Num, Fab_Drawing_Num, "
                                                + "Rfq_Num, Rev_Num) values('newQuote.OpenQuote', 'newQuote.CustomerName', 'newQuote.OemName', 'newQuote.Qty' "
                                                + "'newQuote.QuoteNumber', 'newQuote.FdNumber', 'newQuote.RfqNumber', 'newQuote.RevNumber')", insertConnection);

                cmd.ExecuteNonQuery();

            }
        }

        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }

    }

CustomerData.cs:

    class CustomerData
{
    private string _CustomerName;
    private string _OEMName;
    private string _OpenQuote;
    private int _Qty;
    private string _QuoteNumber;
    private string _FdNumber;
    private string _RfqNumber;
    private string _RevNumber;

    public CustomerData()
    {
        // empty constructor
    }

    public string CustomerName
    {
        get { return _CustomerName; }
        set { _CustomerName = value; }
    }

    public string OpenQuote
    {
        get { return _OpenQuote; }
        set { _OpenQuote = value; }
    }

    public string OEMName
    {
        get { return _OEMName; }
        set { _OEMName = value; }
    }

    public int Qty
    {
        get { return _Qty; }
        set { _Qty = value; }
    }

    public string QuoteNumber
    {
        get { return _QuoteNumber; }
        set { _QuoteNumber = value; }
    }

    public string FdNumber
    {
        get { return _FdNumber; }
        set { _FdNumber = value; }
    }

    public string RfqNumber
    {
        get { return _RfqNumber; }
        set { _RfqNumber = value; }
    }

    public string RevNumber
    {
        get { return _RevNumber; }
        set { _RevNumber = value; }
    }
}

And as a reference, here’s how I set up this table in SQLServer:

Open_Quote, date, not null
Customer_Name, varchar(25), not null
OEM_Name, varchar(25), null
Qty, int, not null
Qute_Num, varchar(20), null
Fab_Drawing_Num, varchar(20), not null
Rfq_Num, varchar(10), null
Rev_Num, varchar(10), null

Thanks in advance to anyone who helps me out,

  • Andrew
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T05:43:58+00:00Added an answer on June 14, 2026 at 5:43 am

    Try again with parameters and let us know how it goes.
    http://www.dotnetperls.com/sqlparameter

    Edit: Or what Tieson T. said. That’d be even better just a little more involved.

    To get the data to show in the datagrid, after you do the insert, you can rebind the grid. Make sure your update the datasource so it repulls the data you just inserted. If you have problems, show where/how you are setting the datasource for the grid.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.