Solved

Use a DateTime Picker to update records in a Sql database

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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

626 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