DateTimePicker CheckBox for setting Null

Position is important. Needs to be before EndEdit

Me.TimeSheetBindingSource.EndEdit
If Me.TimeEndDateTimePicker.Checked = False Then
  rowTS = CType(CType(Me.TimeSheetBindingSource.Current, DataRowView).Row, dsMyCo.TimeSheetRow)
  rowTS.SetTimeEndNull()
End

form.designer.vb InitializeComponent bug deleting remaining controls

At top of frm.designer.vb there is following code.
If get really stuck then rem out System.Diagnostics…. and put a breakpoint here
You may want a try catch block around code that opens the form

 

 

List(T).RemoveAll(match as System.predicate) Remove from IEnumerable possibly based on match

Useful
Would encourage more use of List(of )

http://msdn.microsoft.com/en-us/library/wdka673a.aspx

ASP.Net using network SQL Server instead of SQL Server Express for ASPNETDB.mdf

See

http://www.studiocoast.com.au/knowledgebase/6/aspnet/using-sql-server-instead-of-aspnetdbmdf.aspx

ASP.Net convert website project to web application project

The way I did it was:

  • Create a new web application project
  • Close project
  • Copy all items from website project folder into new application folder. The olde files should overwrite any duplicate new items
  • Open web application project
  • Show all files to show folders not included in project shaded out
  • Include each folder not already in project. Which will load any items in that folder
  • Select Master Page
  • Right-Click choose convert project to web application project
  • This creates designer.vb files
  • Try now

“Input String was not in the correct format” – on Bindingsource

Check all textbox or other controls with bindings.
Did you set the value of one programmatically to wrong format. E.g. Number binding, but text put in.
Bindingsource row will remain rowstate.detached until resolved.

Changing Settings at Runtime in working project and referenced assemblies (or projects) ( including connection strings )

 
I like and need this.
 
Put this in ApplicationEvents
 

Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup
    SetConnectionStrings()
End Sub

 

Private Sub SetConnectionStrings()

            Dim sConString As New SqlConnectionStringBuilder
            sConString.MultipleActiveResultSets = True
            sConString.IntegratedSecurity = True

            Select Case My.Computer.Name.ToUpper
                Case “Computer1”
                    sConString.DataSource = My.Computer.Name
                Case “Computer2”
                    sConString.DataSource = My.Computer.Name ‘+ “\SQLEXPRESS”
                Case Else
                    sConString.DataSource = “<your server name>”
            End Select

            My.Settings.conStringSettings = New System.Configuration.ConnectionStringSettings
            My.Settings.conStringSettings.ProviderName = System.Data.SqlClient 

            sConString.InitialCatalog = “<your initial catalog>”
            My.Settings.<name of saved system.configuration.connectionstringsettings>.ConnectionString = sConString.ConnectionString
            My.Settings(<name of saved connection setting) = sConString.ConnectionString
            Global.<referenced assembly name>.My.MySettings.Default(“<name of saved connection setting>”) = sConString.ConnectionString
            ‘MessageBox.Show(Global.BC.My.MySettings.Default.conStrSOP)

End Sub

 

value cannot be null. parameter name objecttype. Handles refer to controls which do not exist

 
 
Form designer will not open
Problem is that some code handles refer to controls that do not exist
Resolve these in the code then it should open.
 
I also found near this time that all of my BindingNavigator controls had been deleted
 

Late Binding e.g. to Office, Excel, Word etc

 
Option Strict Off
‘Early binding would require COM reference to Excel which brings in
‘   Microsoft.Office.Core
‘   Microsoft.Office.Interop.Excel
‘Imports Microsoft.Office.Interop
‘However late binding requires Option Strict Off
 
Public Class cls
    Private Sub CopyClipboardToExcel(Optional ByVal MyNewFileName As String = "")
        ‘Late Binding or distribute reference
        ‘http://msdn.microsoft.com/en-us/library/0tcf61s1.aspx
        Try
            ‘Dim xlApp As Excel.Application
            Dim xlApp As Object = CreateObject("Excel.Application")
            Dim xlBook As Object = xlApp.Workbooks.Add
            Dim xlSheet As Object = xlBook.Worksheets(1)
            xlSheet.Range("A1").Select()
            xlSheet.Paste()
            Call FormatExcelSheet(xlApp)
            ‘xlSheet.Cells(2, 2) = "This is column B row 2"
            xlSheet.Application.Visible = True
            If MyNewFileName <> "" Then
                xlSheet.SaveAs(MyNewFileName)
                ‘ Optionally, you can call xlApp.Quit to close the workbook.
            End If
        Catch ex As Exception
            If IsT1 Then
                Throw New ApplicationException(ex.Message, ex)
            End If
        End Try
    End Sub
End Class
 

Use of SQL OUTPUT parameter with INSERT to get Identity

 
 
        Private Const InsertToolSQL As String = "INSERT INTO [Production].[Tool] ( Bin, DateLastStockCheck, DieIntroDate, DieLastUpdate, ID, NoOfTools, Notes, QtyInAvailable, QtyInRepair, QtyOut, SetNo, Tool, ToolStoresLastUpdateNowFromToolLog, ToolSupplierID, ToolTypeID) VALUES (@Bin, @DateLastStockCheck, @DieIntroDate, @DieLastUpdate, @ID, @NoOfTools, @Notes, @QtyInAvailable, @QtyInRepair, @QtyOut, @SetNo, @Tool, @ToolStoresLastUpdateNowFromToolLog, @ToolSupplierID, @ToolTypeID); SELECT @NewID = IDENT_CURRENT(‘Production.Tool’)"
 
        Private Const NewIDParameterName As String = "@NewID"
 
            Dim command As New SqlCommand
            SetCommonParameters(cTool, command)
            command.Parameters.Add(NewIDParameterName, SqlDbType.Int)
            command.Parameters(NewIDParameterName).Direction = ParameterDirection.Output
 
            Try
                ExecuteNonQuery(command, InsertToolSQL)
                cTool.ID = CType(command.Parameters(NewIDParameterName).Value, Integer)
            Catch ex As Exception
                Throw ex
            End Try