Jump to content

[Resolvido] DateTimePicker


hypz
 Share

Recommended Posts

Boas, eu estou a tentar passar as datas duma form para a outra quando faço um carregamento. Aqui vai o código das duas forms.

Form Carregamento:

Dim provider As String
	provider = "provider = Microsoft.ACE.OLEDB.12.0;Data Source=Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Documents and Settings\hypz\Ambiente de trabalho\pap_teste.accdb; persist security info = false;"
	Dim con As New OleDbConnection(provider)
	con.Open()
	Dim a, mont As Integer
	Dim datacar As Date
	a = TextBox1.Text
	mont = TextBox2.Text
	datacar = DateTimePicker1.Value
	Dim sql As String = "Update Carregamento set Valor_Base=" & mont & " where Cod_Cliente=" & a & "And Data_Carregamento=" & datacar
	MsgBox("Carregamento efetuado com sucesso !", 64, "Carregamentos")
	Dim sqlcom As New OleDbCommand(sql, con)
	Dim nr As Integer
	nr = sqlcom.ExecuteNonQuery()
	con.Close()
	Dim fat As New listarcarregamento(a, mont, datacar)
		fat.Show()
		Me.Close()

Form Listar Carregamento:

Public a, mont As Integer
Public datacar As Date
Public cod_ut, no_u, nick_u As String
Public Sub New(ByVal a, ByVal mont, ByVal datacar)
	MyBase.New()
	InitializeComponent()
	Me.a = a
	Me.mont = mont
	Me.datacar = datacar
End Sub
Private Sub listarcarregamento_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
	Dim provider As String
	provider = "provider = Microsoft.ACE.OLEDB.12.0;Data Source=Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Documents and Settings\hypz\Ambiente de trabalho\pap_teste.accdb; persist security info = false;"
	Dim con As New OleDbConnection(provider)
	con.Open()
	Dim sql As String = "Select * from Utilizador where Cod_Cartao=" & a
	Dim da As OleDbDataAdapter
	da = New OleDbDataAdapter(Sql, con)
	Dim ds As DataSet
	ds = New DataSet()
	da.Fill(ds)

	Dim db As OleDbDataAdapter
	db = New OleDbDataAdapter(Sql, con)
	Dim dx As DataSet
	dx = New DataSet()
	da.Fill(dx)

	nick_u = dx.Tables(0).Rows(0)("Nick_Utilizador").ToString()

	TextBox1.Text = a
	TextBox2.Text = mont
	TextBox3.Text = nick_u
	DateTimePicker1.Value = datacar

Se eu puser DataTimerPicker1.MaxDate ou MinDate ele não mexe nas datas, mas se puser Value ele vai buscar as horas, e eu na base de dados tenho Data Simples sem horas, apenas 01-01-2001

Edited by Caça
GeSHi
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.