Tuesday, September 6, 2011 | By: nika perales

OLEDB Error "IErrorInfo.GetDescription failed with E_FAIL(0x80004005)."

I was recently working on a software system that uses either msaccess or mysql for its backend. Everything worked well while i was using mysql for the backend but suddenly out of nowhere this error "IErrorInfo.GetDescription failed with E_FAIL(0x80004005)" pops-up out of nowhere, i have traced and re-traced my code and it turned out that the culprit was a query that used a mysql built in function for strings. After getting rid of the mysql function everything ran smoothly. I'm posting this in the hopes that it may help someone who encounters similar error...
Friday, August 12, 2011 | By: nika perales

VB.net: connect to ms access database

Here's how to connect to an MS Access Database from VB.Net and add a new record. The sample code uses the OleDbConnection object as a means of connecting to the MS Access Database...

Imports System.Data

Public Class UsingMsAccess


Private Sub AddNewRecord()
'Replace path to "accessdatabasepath" with the actual path to the ms access database
	'example C:\testApp\data\mydata.mdb
        Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=accessdatabasepath"
        Dim dbConnection As DbConnection = New OleDbConnection(connectionString )
	
        Dim queryStr As String = "SELECT [Employees].* FROM [Employees]"
        Dim dbCommand As DbCommand = New OleDbCommand
        
        dbConnection.Open()
	dbCommand.CommandText = queryString
        dbCommand.Connection = dbConnection

        Dim dataAdapter As DbDataAdapter = New OleDbDataAdapter
        Dim commandBuilder as DbCommandBuilder= New OleDbCommandBuilder(dataAdapter)
	dataAdapter.SelectCommand = dbCommand
        Dim MydataSet As DataSet = New DataSet
        dataAdapter.Fill(MydataSet,"Employees") 'where employees is the name of the datatable
        
	dim NewRow as datarow = MydataSet.tables("Employees").Newrow
	NewRow("Name") = "sammy" 'Replace ("Name") with your own table field name
	NewRow("Age") = 27
	
	MydataSet.tables("Employees").Rows.Add(NewRow)
	dataAdapter.Update(MydataSet,"Employees")
	MydataSet.tables("Employees").AcceptChanges()

End Sub
 
Wednesday, August 10, 2011 | By: nika perales

Open PDF File using Vb6

Code snippet to open a pdf file at a click of a button in vb6

Dim acroRdrPath As String, pdfFilePath As String
Private Sub Command1_Click()

acroRdrPath = "C:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32.exe" 

pdfFilePath = "c:\my documents\260_2C05.pdf"



Shell acroRdrPath & " " & pdfFilePath , vbNormalFocus

End Sub
 

XHTML: Open link in new window

the target attribute has been deliberately removed from xhtml, thus making it difficult for people getting started creating websites using xhtml unable to open links in new windows like in html. Here's the code to help you open a target link in a new window

add this to the head or to an external file which you can reference
function targetBlank (url) {
  blankWin = window.open(url,'_blank','menubar=yes,toolbar=yes,location=yes,directories=yes,fullscreen=no,titlebar=yes,hotkeys=yes,status=yes,scrollbars=yes,resizable=yes');
}
 

then add the onlick event like this
The test domain in a new window
Tuesday, July 26, 2011 | By: nika perales

Simplest Form Fade effect for VB.net

here's a simple fade effect that you can add to your WinForms application. With this code you'll be able to make a form Fade in on load and fade out on close.


'Handle Fade in of form
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)_
Handles MyBase.Load
fade_in()
End Sub

'Handle Fade Out of form
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
fade_out()
End Sub

'Fade in
Public Sub fade_in()
For FadeIn = 0.0 To 1.1 Step 0.1
Me.Opacity = FadeIn
Me.Refresh()
Threading.Thread.Sleep(100)
Next
End Sub


'Fade out:
Public Sub fade_out()
For FadeOut = 90 To 10 Step -10
Me.Opacity = FadeOut / 100
Me.Refresh()
Threading.Thread.Sleep(50)
Next
End Sub