Solved

Use a DateTime Picker to update records in a Sql database

Posted on 2016-08-30
3
33 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 85

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

Industry Leaders: 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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

728 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