How to avoid Error Invalid Use of Null

0 comments

Posted on 7th May 2010 by Admin in Database Programming |Visual Basic 6

, , ,

How to avoid error Invalid use of null in Visual Basic 6
How to Use Do While orSequential reading in database

'Declaration
ConstmCon ="Provider=MSDASQL.1;Persist Security Info=False;Data Source=ipayroll"
'Note : Please change the connection string to make it work, this is my sample connection string in payroll system I developed.
Sub Load_Employee()
On Error GoTo errHandler
Dim rs1 As New ADODB.Recordset
Dim mSQL As String
cboName.Clear
With rs1
mSQL = "Select FirstName,FirstName,MI From Employee Where Status <> 'Inactive' order by LastName"
.Open mSQL, mCon, adOpenDynamic, adLockReadOnly
Do While Not .EOF
If (not isnull(!LastName) or !LastName <> "") And(not isnull(!FirstName) or !FirstName <> "")then
Ifnot isnull(!MI) or !MI <> "" then 'sometime Middle name is optional
cboName.AddItem !LastName & "," & !FirstName & " " & Right(!MI,1) & "."
Else 'Middle name is null or blank
cboName.AddItem !LastName & "," & !FirstName
End If
End if
.MoveNext 'Move point to next record
Loop
.Close 'Close database after using
End With
Exit Sub
errHandler:
MsgBox Err.Number & Err.Description
End Sub

Data Shaping and Data Object Information Using ADODB and ADOX

0 comments

Posted on 1st May 2010 by Admin in Database Programming |Visual Basic 6

, ,

This class allows you to obtain information about a database using ADOX, Microsoft’s new extensions to ADO that allow you to set and read information about database objects such as tables, fields, and indexes. It also includes a function that returns a shaped recordset (a recordset that includes a child recordset as a column) without you having to write the complex SQL syntax for Shaping.
According to Microsoft’s documentation, the Access JetOLEDB provider is the only one that fully supports ADOX. However, most of the the functions in the class have been tested with SQL Server 7.0, where they work fine. They should work with other providers (current and future) to the degree that they support the ADOX functionality included in this class.
Reviewing and using this class is an excellent way to familiarize yourself with Shaping and ADOX, which will undoubtedly soon become widely adopted technologies.

Download Project

Sample DMO, RDO, DAO and ADO Demonstration

0 comments

Posted on 1st May 2010 by Admin in Database Programming |Visual Basic 6

, , , , ,

The program demonstrates major VB capabilities of database accessing. It demonstrates usage of DMO, RDO, ADO and DAO data access to local database and SQL database, too. It also shows a few abilities that are extremely suitable for usage in DB application, but they are not entirely documented in the documentations dedicated to VB databases programming as well as in the MSDN.
To enable all features of this demo, you must copy the provided access database to a SQL Server database and create a DSN for the latter. Follow the instructions in the readme.htm file.

Download Project

Download File

Customers Inventory System

0 comments

Posted on 1st May 2010 by Admin in Database Programming |Visual Basic 6

, , ,

This application is suitable for a car shop. Whenever the mechanic finish a job on a car the only thing he has to do is to use the service wizard and select the parts he used from a list and the number of the parts. The application substract the number of parts used from the inventory and gives the subtotal and total price.

Download Project

Download Project



Crystal Reports VB-SQL Writer/Helper

0 comments

Posted on 30th April 2010 by Admin in Database Programming |Visual Basic 6

, , ,

The application writes code for anyone developing using crystal reports and SQL Server. It generates the necessary ‘TTX’ and the ‘RPT’ files from an SQL statement, and then writes all the necessary Code into a window. You can then copy-paste it into a form, and immediately use it in your application. You must have Crystal Reports to use this great tiny app.

Download Project

Download File