Thursday, June 25, 2009

Populating a .NET Gridview using PostGreSQL


This is an unlikely scenario in a company: a .NET app that needs to connect to PostGreSQL, but it's seamless when you use a Data Access Component from Devart. Then all you have to do is add a reference to your project and import the namespace.

Here's a diagram representing objects available for data access to bind to a gridview. Blue groups represent objects, yellow rectangles are methods, rounded rectangles are parameters.


Monday, June 15, 2009

Web page Analysis 03


Here's a more involved approach for showcasing design work. Requires a bit more manual labor as far as making pages.

Web page analysis 2


Here's the result of analyzing another designer website, which seems simpler when you navigate it but it actually is somewhat more complicated, although pretty good as well.


Web Page Flow Analysis 1


I had the urge to do navigation analysis of some websites that feature web design work. Here is the result of one website. Simple but works very well.

Tuesday, June 09, 2009

XML to Dataset in .NET

I've been exploring the various ways that .NET offers to parse XML files. Luckily it seems like the more I learn, the simpler ways I discover to do a small task. This small task is to read an XML file and show it in a DataGrid. I found it in this website .


Putting it all together


You will need to add an XML file into your build. For this sample, this is the XML file. <?xml version="1.0" encoding="utf-8" ?><family> <name gender="Male"> <firstname>Tom</firstname> <lastname>Smith</lastname> </name> <name gender="Female"> <firstname>Dale</firstname> <lastname>Smith</lastname> </name></family>


In a new VB Windows form, add a DataGrid, call it grdData. Add a button to handle your event, and put this code:

Imports System
Imports System.Data
Imports System.Data.SqlClient

Public Class ReadXMLtoDataset

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim dsPubs As New DataSet()
' Read in XML from file
dsPubs.ReadXml("C:\mySandbox\vbSandbox2\vbSandbox2\scoreTableXML\myScores.xml")
' Bind DataSet to Data Grid
grdData.DataMember = "name"
grdData.DataSource = dsPubs
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
End Class


This is a simple way of putting together a quick bind to an XML file.

Tuesday, March 03, 2009

BIND Using DataReader.

Good for single values.

cn As New pg.PgSqlConnection(String)
cmd As New pg.PgSqlCommand
dr As pg.PgSqlDataReader

cn.Open()
cmd.commandText = "Select * from "
dr = cmd.ExecuteReader

While dr.Read
textBox.Text=dr.Item("email")
End While

dr.Close()
cmd.Dispose()
cn.Close()

Wednesday, January 28, 2009

Binding XML to GridView in .NET

1) xmlDataSource control.
- Add xmlDataSource control to ASP, with ID
- Codebehind: Add method "data" to control.
- Data might need method MSXML2.ServerXMLHTTP.open
- May need method TransformFile (for xsl)
- Add method Databind()


2) DATASET
- Instantiate a Dataset
- Use Dataset.ReadXML method. Pass Request.PhysicalApplicationPath + "File.xml"
- Set Gridview's Datasource to be dataset.
- May set GridView GridView1.DataMember to a node.
Where: http://www.codeproject.com/KB/aspnet/Bind_XML_file_to_GridView.aspx

Streamreader

' Open a file using StreamReader.ReadtoEnd
' (many other Streamreader methods available)

Dim FILENAME As String = Server.MapPath("CC emails.txt")
Dim objStreamReader As StreamReader
objStreamReader = File.OpenText(FILENAME)
Dim newEmail As String = objStreamReader.ReadToEnd()
objStreamReader.Close()

Monday, January 26, 2009

How to Reset TCP/IP, proxy and DNS In Windows

run as admin in command line.


NETSH INT IP RESET

NETSH WINHTTP RESET PROXY

IPCONFIG /FLUSHDNS