Solved

Use a DateTime Picker to update records in a Sql database

Posted on 2016-08-30
3
24 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
  • 2
3 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks Scott!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now