Solved

Use a DateTime Picker to update records in a Sql database

Posted on 2016-08-30
3
32 Views
Last Modified: 2016-08-30
Hi there. I don't yet have any code for this and am hoping that there is an off-the-shelve piece of code I can use to update records to a Sql database, using a DateTime Picker.
If anyone recently used this control, please share.
if this is the incorrect forum for this kind of help, just let me know, as I can then remove the question.

The question is- I'm looking for a sample of how to commit records to a SQL database using values selected via a DateTime Picker control in VB.net.

I basically just need to see how it works, then I'll continue on my own
0
Comment
Question by:fadiel ras
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 41776237
What you're asking doesn't make a lot of sense. A DateTime Picker is just a control - it shows a value and allows the user to choose a value.

If you want to update records in a database, you can do it several ways. You can use the SQLCommand method, for instance:

Imports System.Data.SQLClient

Using con As New SQLConnection("Your connection string")
  con.Open
  Using cmd As New SQLCommand
    cmd.Connection = con
    cmd.CommandText = "INSERT INTO SomeTable(SomeField) VALUES('" & YourDateTimePicker.Value & "')"
    cmd.ExecuteNonQuery
  End Using
End Using

If you're using bound controls then you have builtin methods for doing this. There are quite a lot of tutorials on this on the MSDN website. Here's one:

https://support.microsoft.com/en-us/kb/308055
0
 

Author Comment

by:fadiel ras
ID: 41776241
thanks. I'm not using bound controls.
I think this is the piece of code I couldn't really find in my research:
cmd.CommandText = "INSERT INTO SomeTable(SomeField) VALUES('" & YourDateTimePicker.Value & "')".

the answer will suffice to get me started, thanks. I'll accept the answer accordingly.
0
 

Author Closing Comment

by:fadiel ras
ID: 41776242
Thanks Scott!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question