Tuesday, 18 December 2012
VB.NET - linq where in clause example
Dim groupsToFind = New List(Of Integer)() From {4, 15, 19, 26, 1, 10, 6, 9, 8, 7, 11, 13, 17, 18, 2, 3, 5, 20, 38, 49}
Dim plain = dsInventory.Tables("Plain").AsEnumerable()
Dim plains = From h In plain _
Group h By GroupName = h.Field(Of String)("Group"), GroupId = h.Field(Of Int32)("group_id") _
Into Group _
Where groupsToFind.Contains(GroupId)
Order By GroupName _
Select GroupName
Friday, 14 December 2012
VB.NET - Excel - How to insert new row above programmatically
Watch Online:
Replace
Dim oexcel As Object
oexcel = CreateObject("Excel.Application")
Dim obook As Excel.Workbook
Dim osheet As Excel.Worksheet
Dim fnExc As String = "C:\Temp\ExcelTest\Test.xlsx"
Dim curLine As Integer = 0
' this should be used only once
obook = oexcel.Workbooks.Add
If oexcel.Application.Sheets.Count() < 1 Then
osheet = CType(obook.Worksheets.Add(), Excel.Worksheet)
Else
osheet = oexcel.Worksheets(1)
End If
osheet.Name = "Payroll Detail Report"
osheet.Range("A1").Value = "Row1"
obook.SaveAs(fnExc)
obook.Close()
obook = Nothing
With
Dim oexcel As Object
oexcel = CreateObject("Excel.Application")
Dim obook As Excel.Workbook
Dim osheet As Excel.Worksheet
Dim fnExc As String = "C:\Temp\ExcelTest\Test.xlsx"
Dim curLine As Integer = 0
' this should be used only once
obook = oexcel.Workbooks.Add
If oexcel.Application.Sheets.Count() < 1 Then
osheet = CType(obook.Worksheets.Add(), Excel.Worksheet)
Else
osheet = oexcel.Worksheets(1)
End If
osheet.Name = "Payroll Detail Report"
osheet.Range("A1").Value = "Row1"
osheet.Range("A1", "A1").Insert(Shift:=Excel.XlDirection.xlDown)
osheet.Range("A1").Value = "Header"
obook.SaveAs(fnExc)
obook.Close()
obook = Nothing
VB.NET - Excel - How to fix error - Selected method of range class failed
Error message is produced while trying to freeze panels
Watch on youtube
Replace
'excel
Dim oexcel As Object
oexcel = CreateObject("Excel.Application")
Dim obook As Excel.Workbook
Dim osheet As Excel.Worksheet
Dim fnExc As String = "C:\Temp\Test.xlsx"
Dim curLine As Integer = 0
' this should be used only once
obook = oexcel.Workbooks.Add
'first
If oexcel.Application.Sheets.Count() < 1 Then
osheet = CType(obook.Worksheets.Add(), Excel.Worksheet)
Else
osheet = oexcel.Worksheets(1)
End If
osheet.Name = "Payroll Detail Report"
osheet.Range("A1").Value = "Header"
osheet.Range("A1", "A1").Select()
oexcel.ActiveWindow.FreezePanes = True
'second
If oexcel.Application.Sheets.Count() < 2 Then
osheet = CType(obook.Worksheets.Add(), Excel.Worksheet)
Else
osheet = oexcel.Worksheets(2)
End If
osheet.Name = "Payroll Detail Report (real)"
osheet.Range("A1").Value = "Header"
osheet.Range("A1", "A1").Select()
oexcel.ActiveWindow.FreezePanes = True
'third
If oexcel.Application.Sheets.Count() < 3 Then
osheet = CType(obook.Worksheets.Add(), Excel.Worksheet)
Else
osheet = oexcel.Worksheets(3)
End If
osheet.Name = "Payroll Summary Report"
'next
If oexcel.Application.Sheets.Count() < 4 Then
osheet = CType(obook.Worksheets.Add(), Excel.Worksheet)
Else
osheet = oexcel.Worksheets(4)
End If
osheet.Move(After:=obook.Worksheets(obook.Worksheets.Count))
osheet.Name = "Weekly Payroll Report - Week 1"
obook.SaveAs(fnExc)
obook.Close()
obook = Nothing
With
'excel
Dim oexcel As Object
oexcel = CreateObject("Excel.Application")
Dim obook As Excel.Workbook
Dim osheet As Excel.Worksheet
Dim fnExc As String = "C:\Temp\Test.xlsx"
Dim curLine As Integer = 0
' this should be used only once
obook = oexcel.Workbooks.Add
'first
If oexcel.Application.Sheets.Count() < 1 Then
osheet = CType(obook.Worksheets.Add(), Excel.Worksheet)
Else
osheet = oexcel.Worksheets(1)
End If
osheet.Name = "Payroll Detail Report"
osheet.Range("A1").Value = "Header"
osheet.Select()
osheet.Range("A1", "A1").Select()
oexcel.ActiveWindow.FreezePanes = True
'second
If oexcel.Application.Sheets.Count() < 2 Then
osheet = CType(obook.Worksheets.Add(), Excel.Worksheet)
Else
osheet = oexcel.Worksheets(2)
End If
osheet.Name = "Payroll Detail Report (real)"
osheet.Range("A1").Value = "Header"
osheet.Select()
osheet.Range("A1", "A1").Select()
oexcel.ActiveWindow.FreezePanes = True
'third
If oexcel.Application.Sheets.Count() < 3 Then
osheet = CType(obook.Worksheets.Add(), Excel.Worksheet)
Else
osheet = oexcel.Worksheets(3)
End If
osheet.Name = "Payroll Summary Report"
'next
If oexcel.Application.Sheets.Count() < 4 Then
osheet = CType(obook.Worksheets.Add(), Excel.Worksheet)
Else
osheet = oexcel.Worksheets(4)
End If
osheet.Move(After:=obook.Worksheets(obook.Worksheets.Count))
osheet.Name = "Weekly Payroll Report - Week 1"
obook.SaveAs(fnExc)
obook.Close()
obook = Nothing
Watch on youtube
Replace
'excel
Dim oexcel As Object
oexcel = CreateObject("Excel.Application")
Dim obook As Excel.Workbook
Dim osheet As Excel.Worksheet
Dim fnExc As String = "C:\Temp\Test.xlsx"
Dim curLine As Integer = 0
' this should be used only once
obook = oexcel.Workbooks.Add
'first
If oexcel.Application.Sheets.Count() < 1 Then
osheet = CType(obook.Worksheets.Add(), Excel.Worksheet)
Else
osheet = oexcel.Worksheets(1)
End If
osheet.Name = "Payroll Detail Report"
osheet.Range("A1").Value = "Header"
osheet.Range("A1", "A1").Select()
oexcel.ActiveWindow.FreezePanes = True
'second
If oexcel.Application.Sheets.Count() < 2 Then
osheet = CType(obook.Worksheets.Add(), Excel.Worksheet)
Else
osheet = oexcel.Worksheets(2)
End If
osheet.Name = "Payroll Detail Report (real)"
osheet.Range("A1").Value = "Header"
osheet.Range("A1", "A1").Select()
oexcel.ActiveWindow.FreezePanes = True
'third
If oexcel.Application.Sheets.Count() < 3 Then
osheet = CType(obook.Worksheets.Add(), Excel.Worksheet)
Else
osheet = oexcel.Worksheets(3)
End If
osheet.Name = "Payroll Summary Report"
'next
If oexcel.Application.Sheets.Count() < 4 Then
osheet = CType(obook.Worksheets.Add(), Excel.Worksheet)
Else
osheet = oexcel.Worksheets(4)
End If
osheet.Move(After:=obook.Worksheets(obook.Worksheets.Count))
osheet.Name = "Weekly Payroll Report - Week 1"
obook.SaveAs(fnExc)
obook.Close()
obook = Nothing
With
'excel
Dim oexcel As Object
oexcel = CreateObject("Excel.Application")
Dim obook As Excel.Workbook
Dim osheet As Excel.Worksheet
Dim fnExc As String = "C:\Temp\Test.xlsx"
Dim curLine As Integer = 0
' this should be used only once
obook = oexcel.Workbooks.Add
'first
If oexcel.Application.Sheets.Count() < 1 Then
osheet = CType(obook.Worksheets.Add(), Excel.Worksheet)
Else
osheet = oexcel.Worksheets(1)
End If
osheet.Name = "Payroll Detail Report"
osheet.Range("A1").Value = "Header"
osheet.Select()
osheet.Range("A1", "A1").Select()
oexcel.ActiveWindow.FreezePanes = True
'second
If oexcel.Application.Sheets.Count() < 2 Then
osheet = CType(obook.Worksheets.Add(), Excel.Worksheet)
Else
osheet = oexcel.Worksheets(2)
End If
osheet.Name = "Payroll Detail Report (real)"
osheet.Range("A1").Value = "Header"
osheet.Select()
osheet.Range("A1", "A1").Select()
oexcel.ActiveWindow.FreezePanes = True
'third
If oexcel.Application.Sheets.Count() < 3 Then
osheet = CType(obook.Worksheets.Add(), Excel.Worksheet)
Else
osheet = oexcel.Worksheets(3)
End If
osheet.Name = "Payroll Summary Report"
'next
If oexcel.Application.Sheets.Count() < 4 Then
osheet = CType(obook.Worksheets.Add(), Excel.Worksheet)
Else
osheet = oexcel.Worksheets(4)
End If
osheet.Move(After:=obook.Worksheets(obook.Worksheets.Count))
osheet.Name = "Weekly Payroll Report - Week 1"
obook.SaveAs(fnExc)
obook.Close()
obook = Nothing
Thursday, 13 December 2012
VB.NET Excel - Add new row programtically
osheet.Range("A1", "A1").Insert(Shift:=Excel.XlDirection.xlDown)
Whole code - copy and paste
'excel
Dim oexcel As Object
oexcel = CreateObject("Excel.Application")
Dim obook As Excel.Workbook
Dim osheet As Excel.Worksheet
Dim fnExc As String = "C:\Temp\Test.xlsx"
Dim curLine As Integer = 0
' this should be used only once
obook = oexcel.Workbooks.Add
'first
If oexcel.Application.Sheets.Count() < 1 Then
osheet = CType(obook.Worksheets.Add(), Excel.Worksheet)
Else
osheet = oexcel.Worksheets(1)
End If
osheet.Name = "One"
osheet.Range("A1").Value = "Some Value"
osheet.Range("A1", "A1").Insert(Shift:=Excel.XlDirection.xlDown)
obook.SaveAs(fnExc)
obook.Close()
obook = Nothing
Whole code - copy and paste
'excel
Dim oexcel As Object
oexcel = CreateObject("Excel.Application")
Dim obook As Excel.Workbook
Dim osheet As Excel.Worksheet
Dim fnExc As String = "C:\Temp\Test.xlsx"
Dim curLine As Integer = 0
' this should be used only once
obook = oexcel.Workbooks.Add
'first
If oexcel.Application.Sheets.Count() < 1 Then
osheet = CType(obook.Worksheets.Add(), Excel.Worksheet)
Else
osheet = oexcel.Worksheets(1)
End If
osheet.Name = "One"
osheet.Range("A1").Value = "Some Value"
osheet.Range("A1", "A1").Insert(Shift:=Excel.XlDirection.xlDown)
obook.SaveAs(fnExc)
obook.Close()
obook = Nothing
How to fix error: is not a member of 'String'. LINQ
View on YouTube
Replace:
Dim inv = dsInventory.Tables("Something").AsEnumerable()
Dim Inventory = From h In inv _
Group h By GroupName = h.Field(Of String)("Group") _
Into Group _
Select GroupName
curLine = 2
For Each sku In Inventory
osheet.Range("A" & curLine).Value = sku.GroupName
Next
With
Dim inv = dsInventory.Tables("Something").AsEnumerable()
Dim Inventory = From h In inv _
Group h By GroupName = h.Field(Of String)("Group") _
Into Group _
Select GroupName
curLine = 2
For Each sku In Inventory
osheet.Range("A" & curLine).Value = sku
Next
Replace:
Dim inv = dsInventory.Tables("Something").AsEnumerable()
Dim Inventory = From h In inv _
Group h By GroupName = h.Field(Of String)("Group") _
Into Group _
Select GroupName
curLine = 2
For Each sku In Inventory
osheet.Range("A" & curLine).Value = sku.GroupName
Next
With
Dim inv = dsInventory.Tables("Something").AsEnumerable()
Dim Inventory = From h In inv _
Group h By GroupName = h.Field(Of String)("Group") _
Into Group _
Select GroupName
curLine = 2
For Each sku In Inventory
osheet.Range("A" & curLine).Value = sku
Next
Tuesday, 11 December 2012
MSSQL - How to get object names and id's
-- to get object names - you may need this info while trying to rebuild all indexes.
select * FROM sys.objects Order by name
select * FROM sys.objects Order by name
Monday, 10 December 2012
How to fix error Could not load file or assembly 'file:///C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win64_x64\dotnet1\crdb_adoplus.dll' or one of its dependencies. The system cannot find the file specified.
Error Message: Could not load file or assembly 'file:///C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win64_x64\dotnet1\crdb_adoplus.dll' or one of its dependencies. The system cannot find the file specified.
In app.config file
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
Replace with
<startup useLegacyV2RuntimeActivationPolicy="true"><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
Tuesday, 4 December 2012
Tuesday, 20 November 2012
How to fix error "Unable to verify account information" on IPhone 5
I was setting up exchange email on IPhone 5 and was getting this annoying error message:
"Unable to veriry account information"
In my case I had to modify Server info and replace
http://owa.ServerName.com/exchange
with
owa.ServerName.com/exchange
Error message could be little more descriptive anyway...
"Unable to veriry account information"
In my case I had to modify Server info and replace
http://owa.ServerName.com/exchange
with
owa.ServerName.com/exchange
Error message could be little more descriptive anyway...
Monday, 19 November 2012
ASP.NET - How to fix error WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery'. Please add a ScriptResourceMapping named jquery(case-sensitive).
Watch this example online:
I have simple form with text field, required field validator and a button.
When I click the button I am getting error WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery'. Please add a ScriptResourceMapping named jquery(case-sensitive).
To fix it - add the following into web.config file
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None"/>
</appSettings>
Watch Online:
I have simple form with text field, required field validator and a button.
When I click the button I am getting error WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery'. Please add a ScriptResourceMapping named jquery(case-sensitive).
To fix it - add the following into web.config file
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None"/>
</appSettings>
Watch Online:
Subscribe to:
Posts (Atom)