hye there..,i am using Visual Studio 2008 and VB.NET 2008 and SQL Server 2005 as the database. I just finished designing & writing codes for a customer's contract information and , however after it has been connected to the database only one of the datetimepicker can be click, (i put 2 datetimepickers to find date interval) and the rest of the function including in the form are not working! it seems that the form stuck and NOT responding. i cant even close the form using the 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, (disabled the form_load codes [put 'quote']) the both of datetimepicker will work and able to view the date interval (after pressing the 'Calculate Period' button) in addition 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 .if possible, can u show me the right code to make it works??:sad:
Imports System.Data.SqlClient
Imports System
Imports System.Data
Imports System.Windows.Forms.DataGridView
Public Class Cust_info
Dim SqlConnection As New SqlClient.SqlConnection
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 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