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 6534321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:14:12+00:00 2026-05-25T10:14:12+00:00

This might be a very common and old problem, but still I’ve struggled with

  • 0

This might be a very common and old problem, but still I’ve struggled with quite a lot and finally I’m posting it here:

I’ve to insert DateTime in an Access database, but I’m having trouble doing so.
My C# code:

 protected void Button5_Click(object sender, EventArgs e)
    {
        Panel1.Visible = true;
        Panel2.Visible = false;


        String eventname =
            TextBox6.Text;
        String description = TextBox7.Text;

             String coord = TextBox8.Text;

             String venue = TextBox9.Text;

             String time = TextBox10.Text;

             TextBox6.Text = "";
             TextBox7.Text = "";
             TextBox8.Text = "";
             TextBox9.Text = "";
             TextBox10.Text = "";    


        AccessDataSource1.InsertParameters["eventname1"].DefaultValue
            = eventname;
        AccessDataSource1.InsertParameters["description1"].DefaultValue
            = description;
        AccessDataSource1.InsertParameters["coordinator1"].DefaultValue
            = coord;
        AccessDataSource1.InsertParameters["venue1"].DefaultValue
            = venue;
        AccessDataSource1.InsertParameters["time1"].DefaultValue
            = time;
        AccessDataSource1.InsertParameters["time1"].DefaultValue
           = time;
        AccessDataSource1.Insert();

        DataList1.EditItemIndex = -1;
        DataList1.DataBind();
    }

And the corresponding Asp.Net script:

 <asp:AccessDataSource ID="AccessDataSource1" runat="server" 
        DataFile="~/events.accdb" SelectCommand="SELECT * FROM [upcoming]"

        InsertCommand="INSERT INTO [upcoming] ([eventname], [description],[coordinator], [venue],[time])
         VALUES (@eventname1, @description1,@coordinatior1, @venue1, @time1)" >


        <InsertParameters>
          <asp:Parameter Name="eventname1" Type="String" />
          <asp:Parameter Name="description1" Type="String" />
          <asp:Parameter Name="coordinator1" Type="String" />
          <asp:Parameter Name="venue1" Type="String" />
          <asp:Parameter Name="time1" Type="DateTime" />

        </InsertParameters>

    </asp:AccessDataSource>
<asp:Panel ID="Panel2" runat="server">
   <table>
            <tr><td><asp:Label ID="Label6" runat="server" Text="Name:"></asp:Label></td>
           <td class="style1"> <asp:TextBox ID="TextBox6" runat="server" 
                    Height="24px" Width="548px"></asp:TextBox></td></tr>

            <tr><td><asp:Label ID="Label7" runat="server" Text="Description:"></asp:Label></td>
           <td class="style1"> <asp:TextBox ID="TextBox7" runat="server" 
                    Height="155px" TextMode="MultiLine" 
                   Width="555px"></asp:TextBox></td></tr>

            <tr><td><asp:Label ID="Label8" runat="server" Text="Event Coordinators:"></asp:Label></td>
           <td class="style1"> 
               <asp:TextBox ID="TextBox8" runat="server" 
                 Width="548px"></asp:TextBox></td></tr>

           <tr><td> <asp:Label ID="Label9" runat="server" Text="Venue:"></asp:Label></td>
            <td class="style1">
                <asp:TextBox ID="TextBox9" runat="server"  
                 Width="546px"></asp:TextBox></td></tr>

            <tr><td><asp:Label ID="Label10" runat="server" Text="Date &Time:"></asp:Label></td>
            <td class="style1">
                <asp:TextBox ID="TextBox10" runat="server" 
                 Height="23px" Width="543px"></asp:TextBox></td>
                </tr>

           <tr><td> 
               <asp:Button ID="Button5" runat="server" Text="Insert" 
                   onclick="Button5_Click" /></td>
           <td class="style1"> <asp:Button ID="Button6" runat="server" CommandName="Cancel" 
                   Text="Cancel" onclick="Button6_Click" /></td></tr>
            <table/>
</asp:Panel>

Please help me in inserting the datetime through the given mechanism.

  • 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-05-25T10:14:12+00:00Added an answer on May 25, 2026 at 10:14 am

    you’re going to use the method TryParse to handle a possible exception at runtime.

            string time = this.TextBox10.Text;
            DateTime dt = new DateTime();
            if (DateTime.TryParse("12/12/2011", out dt))
            {
                // your code here
            }
    

    Regards

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

Sidebar

Related Questions

This might be very basic question to some but I am struggling for quite
This might be a very newbie question, but I didn't find anything satisfying I
this might be a very very basic question, but what is the best way
This might be a very silly / stupid question, but, my defence is that
I know, this might be a very basic question but I am not 100%
I know it might be a very simple solution for this, but I am
This might be a very basic question, but I am a bit confused about
This is probably a very common question, but I was unable to find an
This is a very common problem when Excel Worksheet or Chart is embedded into
I know this might be very easy to some,, I have a simple string

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.