Can't create or connect to a firebird database? Solved

If you want to create a gdb database by EMS SQL Manager Lite for InterBase & Firebird you need the not obsolete firebird embed version which currently is Download it from Then unpack it in C:\Users\gg\Documents\firebird folder (if "firebird" folder doesn't exist create it). Proceed with the creation wizard and for charset select "none". At the end of the wizard the database is created.
At this point if something goes wrong download, install and execute "Dll Files fixer". You can download it form here: Done. Now you can create and connect to firebird database.

Howto create a firebird DSN for windows 7. Solved

Follow the next procedure: close VWD if opened.
First case. Client Server structure:
First install a Firebird ODBC build from
C:\Windows\SysWOW64>find odbcad32.exe>click on it>Add button>Select Firebird/Interbase(r) driver>in the textbox "Data source name" insert a cutom name>In Database textbox browse your database>In client DLL browse fbclient.dll from your Firebird Application folder>In user database textbox insert database admin username>in "password" textbox insert admin password>In "character set" combobox select NONE. Now test the connectiion>Press the confirm button.
Second case. Embedded server:
First install a Firebird ODBC build from
Second dowload embedded server package from Unpack it in a custom folder.
C:\Windows\SysWOW64>find odbcad32.exe>click on it>Add button>Select Firebird/Interbase(r) driver>in the textbox "Data source name" insert a cutom name>In Database textbox browse your database>In client DLL browse for fbembed.dll from the custom folder in which the embedded server has been unpacked>In user database textbox insert database admin username>in "password" textbox insert admin password>In "character set" combobox select NONE. Now test the connection>Press the confirm button.

How to get MS ReportViewer control in VS Express. Solved

For Windows 7 and later
Visual studio 2013 Express and maybe also Visual studio 2012 supports ReportViewer control!
  1. Download and install Microsoft Visual Studio Express 2013 for Windows Desktop from here:
  2. Download and install MICROSOFT REPORT VIEWER 2012 RUNTIME from here:
  3. Launch Visual Studio. In form design mode go to the controls toolbox>choose elements>clic on browse button>navigate C>windows>assembly>GAC MSIL>>Microsoft.ReportViewer.WinForms.dll. The same procedure for Microsoft.ReportViewer.WebForms.dll for webforms in Vs Express 2013 for Web>clic on it. You will see this new control (highlighted the by red arrow) in the list (click below on the image to see clearly):
  4. Click on OK button in the window and the new ReportViewer control will appear in the toolbox. This control won't stay in the above list, but already is in the toolbox and will persist on it forever, ready to be employed.
    Notice: drag reportviewer on an empty form. After you can insert other controls and resize reportviewer
For Windows XP and previous 
You have to download and install Visual Web developer 2008 Express and Express 2008.
After you have done these installations you can download and install Microsoft Report Viewer Add-on for Visual Web Developer 2008 Express Edition from this webpage:
To get ReportViewer control in your toolbox right click on it and select "Choose elements". Then select Microsoft.ReportViewer.WebForms.dll or Microsoft.ReportViewer.WebForms.dll, depending on which you need. Now click on OK button and Reportviewer control will appear in your toolbox.
Note: with Express 2008 you cannot use whatever firebird Net Provider. The only working firebird net provider client is FirebirdSql.Data.FirebirdClient Download it from:, download n. 12 Old applications give error in win7 and win vista? Solved

In this case application has to be rebuild. Proceed this way:
  1. In IDE>tools>options>Projects and solutions>check "Show always solution"
  2. This way in top Solution explorer 'll appear "Your application solution". Right click. In drop down menu click on "Configuration Manager"
  3. Will appear a window. Go to Platform. Select "New". 'll appear "x86. Select this. In configuration select "debug" or "release"
  4. Now your application folder will be bin\x86\debug or bin\x86\release depending on what configuration you selected.
This way the problem is solved.
Goodbye everybody.

Could not load type System.Runtime.CompilerServices. Solved

I was getting this exception. After searching in guide and in google I found this solution: install net framework 4.5. This way I solved my problem.
My solution could help other developers.
Goodbye everybody

Windows 7. Can't load assembly...Solved

  • Go to Tools>Options...
  • Click the "Projects and Solutions" item.
  • Check the "Always show Solution" checkbox.
  • In Solution Explorer. at top. will appear the solution
  • When you've right-clicked the solution, choose "Configuration Manager".
  • That window will list all of your projects and let you choose a platform. Make sure to change it for both release and debug builds.

Visual Studio 2010. BadImageFormatException? Resolved

This is an exception which occurs when we upgrade a project to a new version of VS Studio in win7 and later. To get rid of the problem follow these steps::
  1. Upgrade the project
  2. Project menu >Project Properties>Compiling>select the x86 the target CPU as in below image

Now your project is fully functioning.

Refresh datagridview after insert, update. Bug fixed.

Notice. There was a bug in this post about refreshing datagridview after insert, update. Now fixed.

Localizing windows forms with ResGen.exe

Frequently isn't so easy to develop a localized widows forms application.
For this reason I want to write this post based on my experience in localization.
For localization you need  to use ResGen.exe this way:
  1. Create two txt file called (for example) resourceEN.txt and resourceIT.txt
  2. In langEN.txt create a list of items to localize this way (in this example we ave two languages (for Italian and for English). On the left hand we have the name of the strings and on the right hand we have the contents. Below are respectively langIT.txt and langEN.txt: 


First you have to check for ResGen.exe in your computer.
Now we'll assume that resourceEN.txt and resourceIT.txt  well be frequently edited before the first release. Assume also that your project folder is "Picture". Therefore for convenience we'll create a batch file this way:

D:\Programmi\Microsoft SDKs\Windows\v6.0A\bin\ResGen "D:\Documents and Settings\gg\Documenti\resources\resourceEN.txt" "D:\Documents and Settings\gg\Documenti\Visual Studio 2005\Projects\Picture\Picture\bin\Debug\language\langEN.resources"

D:\Programmi\Microsoft SDKs\Windows\v6.0A\bin\ResGen "D:\Documents and Settings\gg\Documenti\resources\resourceIT.txt" "D:\Documents and Settings\gg\Documenti\Visual Studio 2005\Projects\Picture\Picture\bin\Debug\language\langIT.resources"
In this batch file:
  1. D:\Programmi\Microsoft SDKs\Windows\v6.0A\bin\ is the directory where in my pc is located ResGen.exe
  2. D:\Documents and Settings\gg\Documenti\resources\ is the directory where I located my resourceEN.txt and resourceIT.txt
  3. D:\Documents and Settings\gg\Documenti\Visual Studio 2005\Projects\Picture\Picture\bin\Debug\language is the target project directory where I want to locate resourceEN.resources and resourceIT.resources
Example of application:
As you ca see I can easily chose a directory where I want to locate .resources files. In my case this directory name is language, in the application directory.
This way every time you edit the txt files you can execute the batch file and refresh .resources files

Now we imagine to have a project to localize.
In this project create a module file Module1. In Module1 we have to put the following code:

Imports System.Resources
Module Module1
    Private Declare Auto Function GetPrivateProfileString Lib "kernel32.dll" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Integer, ByVal lpFileName As String) As Integer

    Private Declare Auto Function WritePrivateProfileString Lib "kernel32.dll" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Integer
    Friend Function IniRead(ByVal Filename As String, ByVal Section As String, ByVal Key As String, Optional ByVal lpDefault As String = "", Optional ByVal bRaiseError As Boolean = False) As String

        Dim RetVal As String = New String(" ", 255)

        Dim LenResult As Integer
        LenResult = GetPrivateProfileString(Section, Key, lpDefault, RetVal, RetVal.Length, Filename)

        Return RetVal.Substring(0, LenResult)

    End Function

    Friend Function IniWrite(ByVal Filename As String, ByVal Section As String, ByVal Key As String, ByVal Value As String, Optional ByVal bRaiseError As Boolean = False) As Boolean
        Dim LenResult As Integer

        LenResult = WritePrivateProfileString(Section, Key, Value, Filename)

       Return IIf(LenResult = 0, False, True)


    End Function
    Public Function GetString1(ByVal str As String)
        Dim rreit As ResourceReader
        Dim str2 As String = "Giorgio"
        If IniRead(My.Application.Info.DirectoryPath & "\settings.ini", "section", "language") = "English" Then
            rreit = New ResourceReader(My.Application.Info.DirectoryPath & "\language\langEN.resources")
            rreit = New ResourceReader(My.Application.Info.DirectoryPath & "\language\langIT.resources")
        End If
        Dim dict As IDictionaryEnumerator = rreit.GetEnumerator
        Dim ctr As Integer

        Do While dict.MoveNext()
            ctr += 1
            If dict.Key = str Then
                str2 = dict.Value
                Exit Do
            End If


        Return str2

    End Function
End Module

The ini file
Now we have to create a ini file called settings.ini.
Put the settings.ini file in the project application directory. In settings.ini put the following two lines:


For example create a button in main windows form and then two msgboxes in a button routine.
MsgBox(GetString1("str2")) and  MsgBox(GetString1("str3"))
Now create a language form called language.vb
In language.vb file contains the following code
Public Class language
Private Sub language_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Disposed

        IniWrite(My.Application.Info.DirectoryPath & "\settings.ini", "section", "language", ComboBox1.SelectedItem.ToString)

    End Sub

    Private Sub language_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        ComboBox1.SelectedItem = IniRead(My.Application.Info.DirectoryPath & "\settings.ini", "section", "language")
        ResizeFormClass.SubResize(Me, 29, 22)

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
        If ComboBox1.SelectedItem <> IniRead(My.Application.Info.DirectoryPath & "\settings.ini", "section", "language") Then
        End If

    End Sub

End Class

This is a simple sample project. Now to call the language form insert in main form a new button to call language form. In click button event put
Now we can select one of two language by combobox1.
Once selected a language we can execute the two msgboxes mentioned above and see the effect. In the msgboxes we'll read the same string meaning, but in two languages: English and Italiano

Refresh Datagridview after update, insert. Resolved

Attention. In this post there was a bug! Now fixed. All depends on Insert routine. In the "Note" table there's an autoincrement field named "counter". The right insert routine is this
Imports FirebirdSql.Data.FirebirdClient
Public Class Edit
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
Dim connection As FbConnection = New FbConnection("servertype=1;username=sysdba;password=masterkey;database=" & My.Application.Info.DirectoryPath & "\Note.gdb")


        ' Start a local transaction.
        Dim fbTran As FbTransaction = connection.BeginTransaction()

        ' Enlist the command in the current transaction.
        Dim command As FbCommand = connection.CreateCommand()
        command.Transaction = fbTran

        command.CommandText = _
          "insert into Note" _
        & " (Title, Note) values ('" & Replace(Me.TextBox1.Text, "'", "''") & "','" _
         & Replace(Me.TextBox2.Text, "'", "''") & "')"

        command.CommandText = _
                      "select max(contatore) as maxcount from note"


        Dim newCustomersRow As DataRow = Note.DataSet1.Tables("Note").NewRow()
        Dim dr As FbDataReader = command.ExecuteReader

        newCustomersRow("counter") = dr.Item("maxcount")

        newCustomersRow("Title") = Me.TextBox1.Text
        newCustomersRow("Note") = Me.TextBox2.Text



                ' main form

    End Sub
End Class
To edit a row use this routine:
Imports FirebirdSql.Data.FirebirdClient
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click

        Dim ObjConnection As New FbConnection()

        ObjConnection.ConnectionString = "servertype=1;username=sysdba;password=masterkey;database=" & My.Application.Info.DirectoryPath & "\note.gdb"

        Dim ObjCommand As New FbCommand()
        ObjCommand.Connection = ObjConnection

        ObjCommand.CommandText = "update note set title='" & Replace(Me.TextBox1.Text, "'", "''") & "', Note='" & Replace(Me.TextBox2.Text, "'", "''") & "'where counter='" & Note.DataGridView1.CurrentRow.Cells("counter").Value & "'"
        Dim customerRow() = Note.DataSet1.Tables("Note").Select("counter ='" & Note.DataGridView1.CurrentRow.Cells("counter").Value & "'")
        customerRow(0)("Title") = Me.TextBox1.Text
        customerRow(0)("Note") = Me.TextBox2.Text

        Note.DataGridView1.Columns("title").HeaderText = GetString1("str6")
        Note.DataGridView1.Columns("Note").HeaderText = GetString1("str7")
        Note.DataGridView1.Columns("counter").Visible = False
                  ' main form

    End Sub
End Class
Instead of strings appear Getstring1 function because the application is localized: let see this post in this blog:

Remove empty rows in text files? Solved

A small code snippet may be very useful in many situations to remove empty rows in text files. Here is the code:
First: in Form1 insert a label by which you indicate to user the directory  where is the converted file: ie C:\beta.tex
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim objFileToRead, objFileToWrite, objFSO, strPathWrite
            OpenFileDialog1.FileName = ""
            OpenFileDialog1.Filter = "Text files .txt|*.txt"
            strPathWrite = "C:\beta.txt"

            objFSO = CreateObject("Scripting.FileSystemObject")

            objFileToRead = objFSO.OpenTextFile(OpenFileDialog1.FileName, 1)
            objFileToWrite = objFSO.OpenTextFile(strPathWrite, 2, True)

            Dim strTemp
            Do While Not objFileToRead.AtEndOfStream
                strTemp = objFileToRead.ReadLine
                If strTemp <> "" Then
                End If

            objFileToRead = Nothing
            objFileToWrite = Nothing
            objFSO = Nothing

            Me.Label1.Text = "You haven't chosed any file"
            Me.Label1.TextAlign = Drawing.ContentAlignment.MiddleCenter
            Me.Label1.Left = (Me.Width - Me.Label1.Width) / 2
        End Try

    End Sub

Can't install .net framework 3.5? Solved

Many people can't install .net framework 3.5. And I was one of them. After many attempts I solved the issue.
Then follow these steps:
  1. Download "Free Uninstaller 1.1" form this link: In this webpage "Scarica"=Download
  2. Free Uninstaller 1.1 is a zip package.  Doesn't need installation.
  3. Double click on it and lauch filefun.exe
  4. Will appear some registry keys red highlighted on the top of the window
  5. The red highlighted registry keys are invalid registry keys. Remove them.
  6. Download the updated Aaron Stebner "dotfix cleanup tool" from here  in the page top left and launch it. This tool clean your system from any net. framework trace. After cleanup you can safely install the .net framework 3.5. 
Same thing if you can't install net framework 4.0 shows error but application works? How to solve the problem

Sometimes the datagridview control show error but the application works normally.
in fact in these cases is sufficient to close the error message and the application works normally.
However one wants that the error message isn't showed.
To eliminate the error message:
  1. Call the datagridview dataerror event
  2. Insert in the event routine this code: e.Cancel = True