hypz Posted June 12, 2012 at 04:23 PM Report Share #462299 Posted June 12, 2012 at 04:23 PM (edited) 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 June 13, 2012 at 10:28 PM by Caça GeSHi Link to comment Share on other sites More sharing options...
petvetbr Posted June 12, 2012 at 06:53 PM Report Share #462339 Posted June 12, 2012 at 06:53 PM (edited) É que a Propriedade Value te devolve um tipo DateTime, basta pegar o componente Date, algo +- assim: Date data= dtPicker.Value.Date Edited June 12, 2012 at 06:53 PM by petvetbr Fernando Lage Bastos - MCP/MCTS/MCPD Link to comment Share on other sites More sharing options...
hypz Posted June 13, 2012 at 08:48 AM Author Report Share #462415 Posted June 13, 2012 at 08:48 AM Obrigado, já funciona 🙂 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now