RSS

Displaying data in the Stored Procedure With Parameter.

Stored Procedure is a program stored in the data base as well as data. It is actually quite unusual, because we expect the stored data in the development of data base is not his program.

The core competency is in SQL Server Store Procedures and Functions (Functions only found in SQL Server 2000).
With the Store Procedure, then the SQL program that we created:
  • can be used anytime.
  • more quickly and efficiently because it is Server Side.
  • easily created and maintained by a small but 'Power Full'.

Strored Making Procedure.
Syntax:

CREATE PROCEDURE nama_procedure
[@ Parameter1 tipe_data_parameter1, ... ... ... .., [@ ParameterNtipe_data_parameterN]
U.S.
SQL or TSQL statement

TSQL is the development of SQL, thus becoming more Powerful.
The following store procedure creation through the Enterprise Manager:
  • Click Stored Procedure in Database Northwind.
  • Right click on Area Name.
  • Select New Stored Procedure.







Change the statement that there is a Stored Procedure the following:



Then To display the data into a form using a stored procedure, create a form like the following picture:


The following program code:

Dim Conn As New ADODB.Connection
Dim rsTransaksi As New ADODB.Recordset
Dim StrSQL As String, OpenConnecting As String

Private Sub Form_Load()
Dim CustomerId As String
 
  CustomerId = InputBox("Please Input Customer ID !")
 
  OpenConnecting = "Provider=SQLOLEDB.1;Persist Security Info=False;" _
      & "User ID=sa;Initial Catalog=NorthWind;Data Source=(local)"
      
  If Conn.State = adStateOpen Then
    Conn.Close
    Set Conn = New ADODB.Connection
    Conn.Open OpenConnecting
  Else
    Conn.Open OpenConnecting
  End If
 
  rsTransaksi.ActiveConnection = Conn
  rsTransaksi.CursorLocation = adUseClient
  rsTransaksi.CursorType = adOpenDynamic
  rsTransaksi.LockType = adLockOptimistic
  rsTransaksi.Open "EXEC CustOrderHist '" & CustomerId & "'"
 
  Set DataGrid1.DataSource = rsTransaksi
 
End Sub




The result:




  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

Free sample Database Source Code

Tools Application


Generate Barcode
RFID Communicated


Database Application

Access To XML
Ado Client-Side
Books File
Complate Ado Sample APP
Connect To Oracle
Create Database
Database XML
Hotel System
Import Data from Access to SQL Server
Library Application


Aplikasi untuk Lembaga Pendidikan
Aplikasi Inventory Menggunakan Komponen DAO
Aplikasi Shipping
Aplikasi Sistem Pakar untuk Pendeteksian Kerusakan Motor
 

Date & Math 


Calculator 1
Calculator 2
Calculator 3
Calculator 4
Convert your system Date to MM/dd/yyyy
Calendar 1
Calendar 2
Blowfish to VB


Files & Directories

Build Test Files
Change a File extension
Change the archive and read-only Attributes of a File
Create a File Association with default icon
Copy Multiple File
Delete a File
Delete Empty
Detect if a File exists
Determain if a File Exists
Drive Browser
File Counter
File Function
File Splitter
File System
Find File
Create Folder
INI File
INI File Manager
My Explorer
Open a Files with its Associated Application

Form Control

3D Labels Controls
3D Data Array
Action Button
Add a 3D Effect to Form, Textboxes, and Labels
Add Columns and Titles Effortlessly to a ListView Control
Align Flexgrid Cells after Adding a Row or Column
Animated Form Unload
Auto-complete Combo Box
Gurhan Button
hoverbutton




Office and Visual Basic


Access Text to Speech Soap
Add Custom Properties to Excel File
Convert Text Cel to String
Create Excel Files
Create Word Documents Files
Data to Word Documents
Using Microsoft Word from Visual Basic for Reporting
Conversion Excel to Access
Excel and VB
Excel and VB With Database
VB with Excel
Excel to Access
Excel To XML
Excel via VB
Create Help Files
Microsoft Acces Password Recovery
Send Email
Send and Received Email
VB to Excel
VB To Word

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

Export SQL Data to a CSV File

Public Function CSVExport(db As DAO.Database, sSQL As String, sDest As String) As Boolean
   ' #VBIDEUtils#************************************************************
   ' * Programmer Name  : Jarot Dian
   ' * Web Site         : www.belajar-pemrograman-vbonline.blogspot.com
   ' * E-Mail           : cybersoft83@gmail.com
   ' * Module Name      : Database_Module
   ' * Module Filename  : Database.bas
   ' * Procedure Name   : CSVExport
   ' * Parameters       :
   ' *                    db As DAO.Database
   ' *                    sSQL As String
   ' *                    sDest As String
   ' **********************************************************************
   ' * Comments         : Export sql data to a CSV File
   ' *
   ' *
   ' **********************************************************************

   Dim record        As Recordset
   Dim nI            As Long
   Dim nJ            As Long
   Dim nFile         As Integer
   Dim sTmp          As String
  
   On Error GoTo Err_Handler
  
   Set record = db.OpenRecordset(sSQL, DAO.dbOpenDynaset, DAO.dbReadOnly)
  
   ' *** Open output file
   nFile = FreeFile
  
   Open sDest For Output As #nFile
  
   ' *** Export fields name
   For nI = 0 To record.Fields.Count - 1
      sTmp = "" & (record.Fields(nI).Name)
      Write #nFile, sTmp;
   Next
   Write #nFile,

   If record.RecordCount > 0 Then
      record.MoveLast
      record.MoveFirst
  
      For nI = 1 To record.RecordCount
         For nJ = 0 To record.Fields.Count - 1
            sTmp = "" & (record.Fields(nJ))
            Write #nFile, sTmp;
         Next
         Write #nFile,
         record.MoveNext
      Next
   End If
  
   Close #nFile
   CSVExport = True
  
   Exit Function
  
Err_Handler:
   MsgBox ("Error: " & Err.Description)

   CSVExport = False
  
End Function

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

Export Access Tables to Other Formats Using a SQL Statement

Write the program code below into the code window.

For intFileSep = Len(opnFileName) To 1 Step -1
    If Mid$(opnFileName, intFileSep, 1) = "\" Then Exit For
Next intFileSep
   
strTempStr = "SELECT * INTO [dBase IV;DATABASE=" + _   
 Left$(opnFileName, intFileSep - 1) + "].[" + _
 Left$(Right$(opnFileName, Len(opnFileName) - intFileSep), _
 Len(Right$(opnFileName, Len(opnFileName) - intFileSep)) - _
 4) + "]" & " FROM ["& tableName &"]"

DatabaseName.Execute strTempStr

Add Module in your project, and then type the following program code.

Dim opnFileName As String
Dim strTempStr As String
Dim tableName As String
Dim intFileSep As Integer
Dim DatabaseName As Database

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

Color To Number

Create a design form as shown below:


This application aims to find Hexa value of RGB color combination. So in addition to displays of color, in the application also produces Hexa value.

Components used include:

  1. Label
    Objects are colored Black Box
  2. Slider
    consists of three sliders, each slider object properties that you need to set the Min of your content with the number 0 and the Max you are content with the numbers 255.
  3. TextBox
    consists of 5 Textbox.

Write the source code as follows: 

Dim SlidValue(1 To 3) As Long

Private Sub mnuAbout_Click()
MsgBox frmNumbersToColors.Caption & " was written by Arthur Liberman (The Coolest " & _
"INC.)" & vbCrLf & "You can reach me at Winner5@newmail.net." & vbCrLf & _
"Credits to Oren for the idia for this program." & vbCrLf & vbCrLf & "Last modified: 01/28/2001," & _
"10:32", vbInformation, frmNumbersToColors.Caption
End Sub

Private Sub mnuExit_Click()
End
End Sub

Private Sub Slider1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 1 Then
    Text1(0).Text = Slider1.Value
    Text4.Text = Val(Text4.Text) - SlidValue(1) + Val(Text1(0).Text)
    SlidValue(1) = Slider1.Value
    Text5.Text = "&H" & Hex(Text4.Text)
    label3.BackColor = Text4.Text
End If
End Sub

Private Sub Slider1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Slider1.SelLength = Slider1.Value
End Sub

Private Sub Slider2_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 1 Then
    Text1(1).Text = Slider2.Value
    Text4.Text = Val(Text4.Text) - (SlidValue(2) * 256) + (Val(Text1(1).Text) * 256)
    SlidValue(2) = Slider2.Value
    Text5.Text = "&H" & Hex(Text4.Text)
    label3.BackColor = Text4.Text
End If
End Sub

Private Sub Slider2_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Slider2.SelLength = Slider2.Value
End Sub

Private Sub Slider3_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 1 Then
    Text1(2).Text = Slider3.Value
    Text4.Text = Val(Text4.Text) - (SlidValue(3) * 65536) + (Val(Text1(2).Text) * 65536)
    SlidValue(3) = Slider3.Value
    Text5.Text = "&H" & Hex(Text4.Text)
    label3.BackColor = Text4.Text
End If
End Sub

Private Sub Slider3_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Slider3.SelLength = Slider3.Value
End Sub

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

Creating Reports With Crystal Report and Database MSSQL 2000

Crystal Reports is a program that can be used to create, analyze, and interpret the information contained in the database or program into various forms of highly flexible reports. Some of the advantages Crystal Report is:

1.          Making statements is not overly complex, thus allowing the program even beginners to create reports without involving a lot of program code.
2.      Integrated with a variety of other programming languages, allowing programmers to use it with their own expertise - their own.
3.          Facilities import of the report containing the results of the popular formats like Microsoft Word, Excel, Access, Adobe Acrobat Reader, HTML, and so forth.

Element Crystal Reports screen does away with the screen element Data Report. It's just that Crystal Reports is equipped with more facilities to develop various reports.
 

A report consists of at least five sections (section), namely:

1.         Report Header that contains information that is only seen once, in early reports, such as title and date of the report.
2.         Page Header that contains information that will be visible on top of each page of the report, such as label-column headings.
3.          Group Header which contains information from the new group.
4.          Details that contains information that will appear one time each record in a table or query relating to the report.
5.         Group Footer contains information after the entire printed record of the group.
6.         Page Footer contains information that will be visible in the bottom of each page of the report, such as page numbers.
7.         Report Footer contains information that will be seen only once, at the end of the report, such as summary or or - average in the final report. 


To view the complete tutorial please click the Link Below: 

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

Create Installation Files

To create installation file in Visual Basic, the steps are as follows:
1.   Click the START menu, Programs, Microsoft Visual Studio, Microsoft Visual Studio Tool, Package & Deployment Wizard. It will show a dialog box Package & Deployment Wizard as shown below:


2.   Then in the box SELECT PROJECT, you specify which project to compile.
3.   Then you click the Package button, to start doing Compilation.
4.   If a message box pops Package & Deployment Wizard, please click the Yes button. The message box appears because the project that youcreated has never been compiled.

 
5.   Choose the type of package you want to create.

 
6.   Click the Next button
7.   Choose the folder where your Package will be Assembled


8.   The Files in the list below will be included in your Package. Click Add to include additional files. Clear the checkbox to the left of the file name to remove a file from the package.


9.   Click Next Button
10. You can create one large cab file or multiple cab file for your package. If you are going to distrube your aplication on floppy disks, yu must create Multiple Cab and specify a cab size on larger than the disks you plan to use. Choose the appropriate option below.


11. Click Next Button
12. Enter the title to be displayed when the setup program is run.


13. Click Next until the last stage. then you click the Finish button.

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

Import Data from excel to MsSQL 2000

Write the program code below into the Object Execution button.


Dim cn As ADODB.Connection
Dim strSQL As String
Dim lngRecsAff As Long
Set cn = New ADODB.Connection
cn.Open "Provider=SQLOLEDB;Data Source=;" & _
"Initial Catalog=;User ID=;Password="
'Import by using OPENDATASOURCE.
strSQL = "SELECT * INTO XLImport6 FROM " & _
"OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0', " & _
"'Data Source=C:\test\xltest.xls;" & _
"Extended Properties=Excel 8.0')...[Customers$]"
Debug.Print strSQL
cn.Execute strSQL, lngRecsAff, adExecuteNoRecords
Debug.Print "Records affected: " & lngRecsAff
'Import by using OPENROWSET and object name.
strSQL = "SELECT * INTO XLImport7 FROM " & _
"OPENROWSET('Microsoft.Jet.OLEDB.4.0', " & _
"'Excel 8.0;Database=C:\test\xltest.xls', " & _
"[Customers$])"
Debug.Print strSQL
cn.Execute strSQL, lngRecsAff, adExecuteNoRecords
Debug.Print "Records affected: " & lngRecsAff
'Import by using OPENROWSET and SELECT query.
strSQL = "SELECT * INTO XLImport8 FROM " & _
"OPENROWSET('Microsoft.Jet.OLEDB.4.0', " & _
"'Excel 8.0;Database=C:\test\xltest.xls', " & _
"'SELECT * FROM [Customers$]')"
Debug.Print strSQL
cn.Execute strSQL, lngRecsAff, adExecuteNoRecords
Debug.Print "Records affected: " & lngRecsAff
cn.Close
Set cn=Nothing 

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

Create Analog Clock

To make Analog clock, please you make design Form As the following figure:

Please set the properties for the object Timer1 interval filled with a value of 1000.

Once you have set, please type the code as follows:

Public Const PI = 3.14159265358979

Enter the code above into the Object Module.

Here is a complete program code making Analog Clock.

Dim x As Integer
Dim y As Integer
Dim z As Integer
Dim g As Integer
Dim s As Integer
Dim d As Integer
Dim i As Integer

Private Sub Command1_Click()
MsgBox Format(Now, "h am")
End Sub

Private Sub Form_Activate()
hora
pinta
End Sub

Private Sub Timer1_Timer()
hora
End Sub

Sub hora()
y = Val(Format(Now, "h"))
g = Val(Format(Now, "n"))
d = Val(Format(Now, "s"))

If y > 12 Then
    x = y - 12
Else
    x = y
End If

If g > 60 Then
    z = g - 59
Else
    z = g + 1
End If

If d > 60 Then
    s = d - 59
Else
    s = d
End If

pinta
End Sub

Sub pinta()
Cls

For i = 1 To 60
    Line (200 + Cos(0.10471 * i) * 100, 200 + Sin(0.10471 * i) * 100)-(200 + Cos(0.10471 * i) * 95, 200 + Sin(0.10471 * i) * 95), RGB(0, 255, 0)
Next i

For i = 1 To 12
    Line (200 + Cos(0.5235 * i) * 100, 200 + Sin(0.5235 * i) * 100)-(200 + Cos(0.5235 * i) * 90, 200 + Sin(0.5235 * i) * 90)
Next i

Circle (200, 200), 10, RGB(255, 0, 0)
Line (200 + Cos((x + 9) * 0.5235) * 60, 200 + Sin((x + 9) * 0.5235) * 60)-(200 + Cos(0.5235 * x) * 10, 200 + Sin(0.5235 * x) * 10), RGB(255, 0, 0)
Line (200 + Cos((x + 9) * 0.5235) * 60, 200 + Sin((x + 9) * 0.5235) * 60)-(200 + Cos(0.5235 * (x + 6)) * 10, 200 + Sin(0.5235 * (x + 6)) * 10), RGB(255, 0, 0)
Line (200 + Cos(0.10471 * (z + 45)) * 100, 200 + Sin(0.10471 * (z + 45)) * 80)-(200 + Cos(0.10471 * (z)) * 10, 200 + Sin(0.10471 * (z)) * 10), RGB(255, 0, 0)
Line (200 + Cos(0.10471 * (z + 45)) * 100, 200 + Sin(0.10471 * (z + 45)) * 80)-(200 + Cos(0.10471 * (z + 30)) * 10, 200 + Sin(0.10471 * (z + 30)) * 10), RGB(255, 0, 0)
Line (200 + Cos(0.10471 * (s + 45)) * 100, 200 + Sin(0.10471 * (s + 45)) * 80)-(200 + Cos(0.10471 * (s + 43)) * 10, 200 + Sin(0.10471 * (s + 43)) * 10)
Line (200 + Cos(0.10471 * (s + 45)) * 100, 200 + Sin(0.10471 * (s + 45)) * 80)-(200 + Cos(0.10471 * (s + 48)) * 10, 200 + Sin(0.10471 * (s + 48)) * 10)

End Sub

 

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS