DateTimePicker not working after connected to database

My form has two datetimepickers, apparently, only one of them workin

Page 1 of 1

0 Replies - 815 Views - Last Post: 14 April 2010 - 08:11 PM Rate Topic: -----

#1 yukirou  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 18-March 10

DateTimePicker not working after connected to database

Posted 14 April 2010 - 08:11 PM

hye there.., I just finished designing & writing codes for a customer information and , however after it has been connected to the database only one the datetimepicker can be click, and the rest of the function including in the form are not working!it seem that the form stuck and NOT responding. :dozingoff: i cant even close the form (X button), so i have to stop the process using compiler (visual studio 2008), however if i press the 'Delete' button before the 'Add' button, it will successfully delete the data.. but if i disconnected the form from the database, the both of datetimepicker will work and able to view the date interval (after pressing the 'Calculate Period' button)= how to make it appear automatically in screen without using the button? below are the code, I try to make some other form.. but it is still the same :no:
Imports System.Data.SqlClient
Imports System
Imports System.Data
Imports System.Windows.Forms.DataGridView

Public Class Cust_info
    
  Dim monthsTotal As Integer



    Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim SqlConnection As New SqlClient.SqlConnection
        SqlConnection.ConnectionString = "Data Source=ADDYADNAN-PC\SQLEXPRESS;Initial Catalog=CBTS;Integrated Security=True"
        'TODO: This line of code loads data into the 'CBTSDataSet.customer_info' table. You can move, or remove it, as needed.
        Me.Customer_infoTableAdapter.Fill(Me.CBTSDataSet.customer_info)
        Me.BringToFront()
        Me.Show()
        c_Id_Text.Enabled = False
        c_Name_Text.Enabled = False
        DateTimePickerStart.Enabled = False
        DateTimePickerEnd.Enabled = False
        con_amnt.Enabled = False
        con_period.Enabled = False
        payMethod.Enabled = False

    End Sub

    Private Sub AddCustBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddCustBtn.Click
        Me.CustomerinfoBindingSource.AddNew()

        c_Id_Text.Enabled = True
        c_Name_Text.Enabled = True
        DateTimePickerStart.Enabled = True
        DateTimePickerEnd.Enabled = True
        con_amnt.Enabled = True
        con_period.Enabled = True
        payMethod.Enabled = True
    End Sub
    Private Sub delCustInfo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles delCustInfo.Click
        Me.CustomerinfoBindingSource.RemoveCurrent()

        c_Id_Text.Enabled = True
        c_Name_Text.Enabled = True
        DateTimePickerStart.Enabled = True
        DateTimePickerEnd.Enabled = True
        con_amnt.Enabled = True
        con_period.Enabled = True
        payMethod.Enabled = True
    End Sub

    Private Sub reset1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles reset1.Click
        c_Id_Text.Clear()
        c_Name_Text.Clear()
        DateTimePickerStart.ResetText()
        DateTimePickerEnd.ResetText()
        con_amnt.Clear()
        con_period.Clear()
        Pay_method.ResetText()

    End Sub

    Private Sub ExitCustInfo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitCustInfo.Click
        ExitDialog.BringToFront()
        ExitDialog.Activate()
        ExitDialog.Show()
    End Sub

    Private Sub back2menu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles back2menu.Click
        Me.Hide()
        FrontPage.BringToFront()
        FrontPage.Activate()
        FrontPage.Show()
    End Sub
    Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs)

    End Sub

   Private Sub DateTimePickerStart_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePickerStart.ValueChanged

    End Sub
    Private Sub DateTimePickerEnd_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePickerEnd.ValueChanged
       
    End Sub

    Private Sub ButCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButCalc.Click
        Dim Con_Start1 As Date = DateTimePickerStart.Value
        Dim con_end1 As Date = DateTimePickerEnd.Value

        monthsTotal = DateDiff(DateInterval.Month, Con_Start1, con_end1)

        Me.con_period.Text = monthsTotal

    End Sub

    Private Sub c_Id_Text_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles c_Id_Text.TextChanged

    End Sub

    Private Sub c_Name_Text_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles c_Name_Text.TextChanged

    End Sub

    Private Sub con_amnt_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles con_amnt.TextChanged

    End Sub

    Private Sub con_period_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles con_period.TextChanged

    End Sub

    Private Sub Pay_method_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Pay_method.SelectedIndexChanged

    End Sub

    Private Sub DataGridView1_CellContentClick_1(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick

    End Sub
   
    Private Sub DateTimePicker2_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePickerEnd.ValueChanged

    End Sub

    Private Sub FillByToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Try
            Me.Customer_infoTableAdapter.FillBy(Me.CBTSDataSet.customer_info)
        Catch ex As System.Exception
            System.Windows.Forms.MessageBox.Show(ex.Message)
        End Try

    End Sub

    Private Sub updateBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles updateBtn.Click
        Me.Validate()
        Me.CustomerinfoBindingSource.EndEdit()
        Me.Customer_infoTableAdapter.Update(Me.CBTSDataSet.customer_info)
        MessageBox.Show("Data has been Updated")
    End Sub
End Class



This post has been edited by yukirou: 14 April 2010 - 08:12 PM


Is This A Good Question/Topic? 0
  • +

Page 1 of 1