IIS show error running ASP.net pages? Solved

Hello friends,
I noticed my 5.1 IIS on windows xp not showing aspx pages. After some troubling, I found the cause of the issue: I needed uninstall and reinstall the .net framework.
If you have many versions of framework installed on your machine you need a working unistalling freeware tool: dotnetfx cleanup. Here's the download page: http://www.filestube.com/b7b587c2f858fd0203e9,g/dotnetfx-cleanup-tool.html

Howto create a DSN

Follow the next procedure: close VWD. First install a Firebird ODBC build from Firebirdsql.org. Then Start>Settings>control Panel>Administrative tools>Data source OBDC>"User DSN" tab>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 "caracter set" combobox select WIN1251. Now test the connession>Press the confirm button.
Goodbye.

Establishing a data connection for Asp.net page

With Visual Web Developer, from Microsoft:

  1. Create an ODBC data source for the database
  2. In default.aspx web form drag and drop a Gridview control
  3. Click on the top right of the Gridview control. Select "new data source". On the page will appear a window with various icons. Select "Database". Click OK.
  4. Noe 'll appear SqlDataSource1 control. Click on "New connection" button.
  5. It'll appear a window. Click on Edit button and select "Other". In the label It'll appear ".Net Framework Data Provider for ODBC"
  6. Below click the option button "Use connection string". Click on "Generate.." button, and select the tab "Computer data source". Then select your data source name. Then OK. Next.
  7. Click on the "Specify a stored procedure or a customized SQL statement" option button. Otherwise you may get a token error message because of the square brackets for a string without white spaces.
  8. You may use "select" statement. Write the select statement. Next. Click on "Test query" button.
  9. Now you should see your table.
  10. For further test start the debug.

Solved datagridview issue of new record editing

The issue, typical in Firebird, consist in the fact that, after you insert a new record with an autoincrement field in a datagridview, we have to exit from the application to be able to edit the new inserted record.

To solve this issue you have to proceed this way:
1) Proceeding for semplicity with SQL Manager 2005 lite software, Call
the autoincrement field "Counter"
2) In the database of interest create a new table called for example "Counter" with only a field named "memcont", type Integer.
3) To insert a record use this routine:
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim ObjConnection As New FbConnection()
Dim connection As FbConnection = New

FbConnection("servertype=1;username=sysdba;password=masterkey;database=" _

& My.Application.Info.DirectoryPath & "\mydb.gdb")
connection.Open()

' Starts 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

Try
command.CommandText = _
"insert into new_table1" _
& " (Clienti, spesa) values ('" & Me.TextBox1.Text & "','"

_
& Me.TextBox2.Text & "')"
command.ExecuteNonQuery()
command.CommandText = _
"delete from counter"
command.ExecuteNonQuery()
'There we make use of the generator GEN_ID function of Firebird with no increment
command.CommandText = _
"INSERT INTO counter(memcont)
VALUES(GEN_ID(new_table1_COUNTER_GEN, 0))"
command.ExecuteNonQuery()
fbTran.Commit()
Catch ex As Exception
MsgBox("Insert a Integer number for field spesa")

fbTran.Rollback()
Finally
ObjConnection.Close()
End Try

'There we create an instance of the new row in the datatable
Dim persRow As DataRow = Principale.DataSet1.Tables("counter").NewRow
If IsDBNull(persRow("memcont")) Then
persRow("memcont") = Principale.DataSet1.Tables("New_table1").Rows.Count
End If
Principale.DataSet1.Tables("counter").Rows.Add(persRow)
'There we create an instance of the row 0 of the "counter" datatable


Dim CustomersRow As DataRow = Principale.DataSet1.Tables("counter").Rows(0)
'There we create an instance of the new row of the "New_table1" datatable
Dim newCustomersRow As DataRow = Principale.DataSet1.Tables("new_table1").NewRow()
' The autoincremnt field value musts reflect the "memcont" value +1
newCustomersRow("counter") = CustomersRow("MEMCONT") + 1
' there we assign to the unique record in the field "memcont" of the datatable "counter" the
new value of the autoincrement field

CustomersRow("MEMCONT") = newCustomersRow("counter")
newCustomersRow("CLIENTI") = Me.TextBox1.Text
newCustomersRow("spesa") = Me.TextBox2.Text


Principale.DataSet1.Tables("new_table1").Rows.Add(newCustomersRow)

Me.Close()

End Sub

Resize form, controls, fonts

At bottom of the form load event put ResizeFormClass.SubResize(Me, percentW, percentH) where percentW is ratio form.width/Int((Screen.PrimaryScreen.WorkingArea.Width), and percentH is ratio form.height/Int((Screen.PrimaryScreen.WorkingArea.Height). If form is maximized, below ResizeFormClass.SubResize(Me, percentW, percentH) put Me.WindowState = FormWindowState.Maximized, at runtime.
At the resolution 1 form resizes and the form width becomes: Int((Screen.PrimaryScreen.WorkingArea(1).Width) * (percentW / 100)), while the form height becomes: Int((Screen.PrimaryScreen.WorkingArea(1).Height) * (percentH / 100)).
When I run the application, at resolution 2, the form width becomes: Int((Screen.PrimaryScreen.WorkingArea(2).Width* (percentW / 100) and the form height becomes: Int((Screen.PrimaryScreen.WorkingArea(2).Height) * (percentH / 100)).
The form resizes not exactly proportionally because Int((Screen.PrimaryScreen.WorkingArea(1).Width) * (percentW / 100))/Int((Screen.PrimaryScreen.WorkingArea(2).Width* (percentW / 100))<>Int((Screen.PrimaryScreen.WorkingArea(1).Height) * (percentH / 100))/Int((Screen.PrimaryScreen.WorkingArea(2).Height) * (percentH / 100)),
but the controls and the fonts resize proportionally.
With this method we resize the form better than other methods because we can set both width and height of the form and because with percentW=100 and percentH=100 the form fills all the working area in the maximized mode and we can set the WindowState property=Maximized without the risk to "lose" any control.
On the other hand, going from the resolution 1280x1024 to the resolution 1024x768 FormHeight1/FormHeight2= Int((Screen.PrimaryScreen.WorkingArea(1).Height) * (percentH / 100))/ Int((Screen.PrimaryScreen.WorkingArea(2).Height) * (percentH / 100))=1.347 and FormWidth1/FormWidth2= Int((Screen.PrimaryScreen.WorkingArea(1).Width) * (percentW / 100))/Int((Screen.PrimaryScreen.WorkingArea(2).Width* (percentW / 100))=1.25. If we make the ratio 1.347/1.25 we find 1.0776. That is the form stretch out about by 7.76%, that isn't so much!
Going form 1280x1024 resolution to 800x600 resolution we have similarly to make the ratio 1.74/1.6=1.0875, that is the form stretch out about by 8.75%.
If we go form 1024x768 resolution to 800x600 resolution similarly we have to make the ratio 1.29/1.28, that is the form stretch out by 0.78%!
In a module paste code below:

Module Module1

Public Class ResizeFormClass
'Original form width.
Private Shared m_FormWidth As Long
Private Shared m_FormHeight As Long



Public Shared Sub SubResize(ByVal F As Form, ByVal percentW As Double, ByVal percentH As Double)
Dim FormHeight As Long
Dim FormWidth As Long
Dim HeightChange As Double, WidthChange As Double



Call SaveInitialStates(F)




'Calculate the new height and width the form needs to be resized to, based on the current avaible screen area.
FormHeight = Int((Screen.PrimaryScreen.WorkingArea.Height) * (percentH / 100))
FormWidth = Int((Screen.PrimaryScreen.WorkingArea.Width) * (percentW / 100))



'Use the Form that is to be resized.
With F
'Change the demensions and position of the form.

.Height = FormHeight
.Width = FormWidth

HeightChange = .ClientSize.Height / m_FormHeight
WidthChange = .ClientSize.Width / m_FormWidth

End With
'Calculate ratio current avaible screen area/form size

'Notify the class that the form has been resized.
SubChangeWithRatio(F, WidthChange, HeightChange)

End Sub

Private Shared Sub SaveInitialStates(ByVal F As Form)


'Use the form that is being resized.
With F
'Check if the form is a MDI form.

'Set the FormWidth and FormHeight variables to the Form's Scale Width and Height.
m_FormWidth = .ClientSize.Width
m_FormHeight = .ClientSize.Height

End With

End Sub


Public Shared Sub SubChangeWithRatio(ByVal F As Form, ByVal RapportoW As Single, ByVal RapportoH As Single)
'uses a recursive routine
For Each ctl As Control In F.Controls
ResizeControlAndIncludedControls(ctl, RapportoW, RapportoH)
Next

End Sub

Private Shared Sub ResizeControlAndIncludedControls(ByRef ctl As Control, ByVal RapportoW As Single, ByVal RapportoH As Single)



Dim ChildCtl As Control

For Each ChildCtl In ctl.Controls

ResizeControlAndIncludedControls(ChildCtl, RapportoW, RapportoH)

Next
ResizeControl(ctl, RapportoW, RapportoH)
End Sub

Private Shared Sub ResizeControl(ByRef ctl As Control, ByVal RapportoW As Single, ByVal RapportoH As Single)
Dim lb As New ListBox, intlH As Boolean
Try
If TypeOf ctl Is ListBox Then


lb = CType(ctl, ListBox)
intlH = lb.IntegralHeight
lb.IntegralHeight = False

ctl.Left = CInt(ctl.Left * RapportoW)
ctl.Top = CInt(ctl.Top * RapportoH)
ctl.Width = CInt(ctl.Width * RapportoW)
ctl.Height = CInt(ctl.Height * RapportoH)

Else

ctl.Left = CInt(ctl.Left * RapportoW)
ctl.Top = CInt(ctl.Top * RapportoH)
ctl.Width = CInt(ctl.Width * RapportoW)
ctl.Height = CInt(ctl.Height * RapportoH)

End If

lb.IntegralHeight = intlH
If TypeOf ctl Is ListView Then
Try
ResizeColumns(ctl, RapportoW, RapportoH)
Catch ex As Exception
End Try
End If
Try
ResizeControlFont(ctl, RapportoW, RapportoH)

Catch ex As Exception
End Try
Catch ex As Exception
End Try

End Sub

Private Shared Sub ResizeControlFont(ByRef Ct As Control, ByVal RapportoW As Single, ByVal RapportoH As Single)

'Resizes the control font and, in the case of some controls, as the listview
' resizes the columns also

Try

Dim FSize As Double = Ct.Font.Size
Dim FStile As FontStyle = Ct.Font.Style
Dim FNome As String = Ct.Font.Name
Dim NuovoSize As Double = FSize



NuovoSize = FSize * Math.Sqrt(RapportoW * RapportoH)
Dim NFont As New Font(FNome, CSng(NuovoSize), FStile)
Ct.Font = NFont

Catch

End Try

End Sub

Private Shared Sub ResizeColumns(ByRef ct As Control, ByVal RapportoW As Single, ByVal RapportoH As Single)

Dim c As ColumnHeader
For Each c In CType(ct, ListView).Columns
c.Width = CInt(c.Width * RapportoW)
Next

End Sub
End Class
End Module

Found two bugs in Visual Basic express + SP1

The properties rows of datagridview and visiblerows.count of datagrid
mark 1 plus record. Done my signal to Microsoft.

Dbms Firebird and Vb.net

Warning: this article has been modified on 17 February 2007

Dbms the Firebird offers excellent performances also regarding other famous dbms. Moreover it is free, it's wheight is around 14 mega. It has a client-server structure and as far as instructions SQL they follow the international standards.
For a comparison with others dbms see here
The last setup for the classic server and superserver can be dowloaded here.
To work with .net applications Firebird needs the .net providers wich you can download here.
Now is more easy to insert indexes and primary keys in the tables.
As editors of SQL there are free applications. One is SQL Manager 2005 Lite for InterBase/Firebird from here. The other is IBEasy+ 1.5.1 from here
SQL Manager 2005 lite is more complete, but with IBEasy+ 1.5.1 you may import tables from Excel, files XML, and Access, but I council to import from files Excel (the import from Access doesn't work and that from files XML works badly).
The tables can directly be exported in
Excel format from Access (clic with the right of the mouse on the table and choose the option “exports”. In order to see how to import tables of Excel consult the guide of IBEasy+ 1.5.1.

Older Posts