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

  • Home
  • SEARCH
  • 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 8037555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:57:48+00:00 2026-06-05T02:57:48+00:00

I have this SqlDataSource in my form: <asp:SqlDataSource ID=SqlDataSource1 runat=server ConnectionString=<%$ ConnectionStrings:ConnectionString %> InsertCommand=INSERT

  • 0

I have this SqlDataSource in my form:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 

        InsertCommand="INSERT INTO [contact] ([Name], [phone], [email], [comment], [time]) VALUES (@Name, @phone, @email, @comment, @time)" 
        oninserting="SqlDataSource1_Inserting" >
        <InsertParameters>
            <asp:ControlParameter ControlID="TBname" Name="Name" PropertyName="Text" Type="String" />
            <asp:ControlParameter ControlID="TBphone" Name="phone" PropertyName="Text" Type="String" />
            <asp:ControlParameter ControlID="TBemail" Name="email" PropertyName="Text" Type="String" />
            <asp:ControlParameter ControlID="TBmessage" Name="comment" PropertyName="Text" Type="String" />
        </InsertParameters>
    </asp:SqlDataSource>

And I have this function which has to save the values of TextBoxes in first four fields and current time in fifth field:

protected void SaveToDB(object sender, EventArgs e)
{
        SqlDataSource1.InsertParameters["time"].DefaultValue = DateTime.Now.ToString();
        SqlDataSource1.Insert();
}

4 of 5 fields get their values from some TextBoxes in my form. now problem is the last field: time which I can’t set it’s value. When the function runs, gives you this error:

Exception Details: System.Data.SqlClient.SqlException: String or
binary data would be truncated. The statement has been terminated.

What should I do?

thank you for taking time.

  • 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-05T02:57:50+00:00Added an answer on June 5, 2026 at 2:57 am

    try this:

    DateTime.Now.ToShortDateString(); 
    

    “String or binary data would be truncated.” usually has to do with fields in databases having a smaller size then what you’re trying to put into it.

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

Sidebar

Related Questions

I have a SqlDataSource SelectCommand on my .aspx page. <asp:SqlDataSource ID=SqlDataSource1 runat=server ConnectionString=<%$ ConnectionStrings:MyConnectionString
I have this code <asp:GridView ID=gvCentersList runat=server AutoGenerateColumns=False DataKeyNames=CenterID DataSourceID=SqlDataSource1 CssClass=gv-classic> <Columns> <asp:TemplateField HeaderText=>
I dream of creating a control which works something like this: <asp:SqlDataSource id=dsFoo runat=server
I have in my Web a GridView that use SqlDatasource to insert data into
I have this membership site setup on my local machine using the ASP.NET membership
I have an asp.net application in which I am inserting into an sql table
I have this homework in Visual Web Developer (ASP.NET - C#) and unfortunately I
I have a GridView in ASP.net which is filled from an SqlDataSource. one of
I have ALWAYS used the SQLDataSource to update my records in my SQL Server
I have this situation where I have a SqlDatasource control and the select query

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.