Wednesday, April 27, 2011

Prectical Prectise Questions

Q1] Create a database for vehicle service job contains job-master(job-no, vehicle-no, attend(y/n), type of job (accident, service, color), job-description, entrydate, deliverydate). Write a vb.net code which provide facility of DML, navigation and search operation. Provide search facility on vehicle-no and jobtype jointly, Display result in datagridview.


Q2] Create a webpage which display information about a medical shop. The registered user can order medicine online. Provide appropriate constraints to accept user's personal information using form. Also provide facility to order for medicines which provide facility to order multiple medicines and calculate total Bill-amount.


Q3]
a) Write a java code which accept names and age of 10 students. Sort the names of students agewise in ascending order. Display the names of students using thread class at interval of one seconds.
b) Write a java application which display a pentagon containing a circle within the pentagon where the circumference of the circle touches to the edges of the pentagon. Provide separate colors to both the objects. Display your name in center position of the circle.

Tuesday, April 26, 2011

Solution of Report Daywise Weekwise & Itemwise

Imports System.Data.OleDb
Imports System.Data
Public Class Form1
    Dim cn As OleDbConnection
    Dim da As OleDbDataAdapter
    Dim ds As DataSet
   
'Daywise Report
 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Report1.mdb;Persist Security Info=True")
        da = New OleDbDataAdapter("SELECT BillDate AS [BillDate By Day], Sum(Rest.TotalBill) AS [Sum Of TotalBill] FROM Rest GROUP BY BillDate", cn)
        ds = New DataSet
        da.Fill(ds)
        DataGridView1.DataSource = ds.Tables(0)
    End Sub

'Weekwise Report
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'To Find Week      
        Dim sdate As Date = New Date(Today.Year, Today.Month, 1)
        Dim edate As Date = sdate.AddDays(6)
        While (edate.Month = Today.Month)
            cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Report1.mdb;Persist Security Info=True")
            da = New OleDbDataAdapter("SELECT Sum(TotalBill) FROM Rest Group by BillDate Having BillDate >= #" & sdate & "# and BillDate <= #" & edate & "#", cn)
            ds = New DataSet
            da.Fill(ds)
            DataGridView1.Columns.Add("Week", "Week")
            DataGridView1.Columns.Add("Total", "Total Collection")
            If ds.Tables(0).Rows.Count > 0 Then
'Dynamically add rows to gridview               
   DataGridView1.Rows.Add()
   DataGridView1.Rows(i).Cells(0).Value = sdate.ToString & "-" &  edate.ToString
   DataGridView1.Rows(i).Cells(1).Value = ds.Tables(0).Rows   (i).Item(1).ToString
End If
'Find Next Week           
            sdate = sdate.AddDays(7)
            edate = sdate.AddDays(6)
        End While
       
    End Sub

'Itemwise Report
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Report1.mdb;Persist Security Info=True")
        da = New OleDbDataAdapter("SELECT Itemname , Sum(Rest.TotalBill) AS [Sum Of TotalBill] FROM Rest GROUP BY Itemname", cn)
        ds = New DataSet
        da.Fill(ds)
        DataGridView1.DataSource = ds.Tables(0)
    End Sub
End Class

Prectical Prectise Questions

Q1] Create a database, which maintain student information. The databse must contain personal information regarding students and their academic information. Desing GUI forms which provide facility of insert, update, delete, navigation of records and search specific records based on city and name.

Q2] Create webpages for placement agency. This website accepts biodata of clients, including personal details and educational qualification. Also provide appropriate constraints to check that the email address and phone numbers are valid. Name, address and educational qualification fields are compulsory. Provide appropriate webpage design including required images.

Q3]
a] Write a javacode which accept start and end alphabates in sequance and print from start position till end position providing one second intervals using thread.
b] Create on applet which display name of your city within a triangle which is inside a circle and vertices of triangles are on the circumference of the circle. Provide separate colors to the triangle and circle.

Monday, April 25, 2011

Prectical Prectise Questions

Q1] Create an application which maintain information about the score of students of BCA studying in 1st to 6th sem. Design appropriate databse and store information using GUI forms. List out name of topper from each semester and search top three students based on selected semester. Also display names of failures. Provide insert, update, delete and search facility.

Q2] Create webpage for ice-creame parlour and various products provided by the parlour. The website provide facility to accept orders online. It check validity of product (must be available in list). Total order quantity must be greater than zero. Calculate total bill rate and tax (10% of total amount). Calculate bill amount.

Q3]
a] Write a java code (Application or applet) Which display current time and date. Use thread class to execute the code.
b] Write java application which accept a string and display the string in reverse order by interchanging its odd positioned characters with even positioned characters.

Prectical Prectise Questions

Q1] Create GUI application which perform add, delete, insert, update, search and navigation operation for following database.
Create appropriate tables to maintain information about various items sold by the restaurant. Also maintain information about bills generated for customers.
Generate reports which display week-wise and day-wise bill-collection and item-wise bill collection.

Q2] Create and design website for a restaurant. Display various special offers given by the owners. Also provide online order facility.

Q3]
 a]Create an applet which display rectangle having a circle inside the rectangle.
b] Create an application which accept ten
names. Display the names using thread at an interval
of 2 seconds.

Friday, April 22, 2011

Basic PayPal integration using a HTTP GET request

To add a simple PayPal button to your website you could use some code like this:
 // Variables
string business = "youremail@example.com";
string item_name = "Screwdriver set";
string item_number = "1054b";
decimal amount = 10.99m;

// Build the PayPal url
StringBuilder sb = new StringBuilder();
sb.Append("cmd=_xclick");
sb.Append("&business=" + HttpUtility.UrlEncode(business));
sb.Append("&no_shipping=1");
sb.Append("&currency_code=GBP");
sb.Append("&lc=GB");
sb.Append("&bn=PP-BuyNowBF");
sb.Append("&item_name=" + HttpUtility.UrlEncode(item_name));
sb.Append("&item_number=" + HttpUtility.UrlEncode(item_number));
sb.Append("&amount=" + HttpUtility.UrlEncode(amount.ToString()));

// Redirect to PayPal to make secure payment
Response.Redirect(@"https://www.paypal.com/cgi-bin/webscr?" + sb.ToString());
Depending on the country you are using PayPal in you may have to change the lc and currency_code lines.
Put this in a button click event on your page, customise the variables as required and you're all set!

Thursday, April 14, 2011

Send Email From Your Web Application Using Your Gmail Account

Imports System.Net.Mail

Dim from As String = ""
 'Replace this with your own correct Gmail Address
Dim to1 As String = ""
 'Replace this with the Email Address to whom you want to send the mail
Dim mail As New System.Net.Mail.MailMessage

mail.To.Add(to1)
mail.From = New MailAddress(from, "CAM", System.Text.Encoding.UTF8)
mail.Subject = "This is a test mail"

mail.SubjectEncoding = System.Text.Encoding.UTF8
mail.Body = "This is Email Body Text"

mail.BodyEncoding = System.Text.Encoding.UTF8
mail.IsBodyHtml = True

mail.Priority = MailPriority.High

Dim client As SmtpClient = New SmtpClient()
'Add the Creddentials- use your own email id and password

client.Credentials = New System.Net.NetworkCredential(from, "")
 ' Enter password in string
client.Port = 587 ' Gmail works on this port
client.Host = "smtp.gmail.com"
client.EnableSsl = True ' Gmail works on Server Secured Layer

Try     
     client.Send(mail)
      HttpContext.Current.Response.Write("Succeed")
Catch ex As Exception
      HttpContext.Current.Response.Write(ex.Message)
End Try

Tuesday, April 12, 2011

Database Backup/Restore Utility With SQL-DMO Using VB.NET

Introduction to SQL-DMO
SQL-DMO uses the Microsoft® SQL Server™ ODBC driver to connect to and communicate with instances of SQL Server.  SQL-DMO clients require the SQL Server ODBC Driver, version 3.80 or later, which ships with SQL Server 2000.  All required SQL-DMO components are installed as part of an instance of the Microsoft® SQL Server™ server or client. SQL-DMO is implemented in a single dynamic-link library (DLL). We may develop SQL-DMO applications on either a client or a server.

The following are the main declarations of SQL-DMO objects used:

Imports SQLDMO 

Dim oSQLServer As New SQLDMO.SQLServer
Dim WithEvents oBackup As New SQLDMO.Backup
Dim WithEvents oRestore As New SQLDMO.Restore

oSQLServer is used to connect to SQL Server instance, oBackup to work with the backup operation and oRestore to work with the restore operation.  The word WithEvents raises the respective PercentComplete (gives the progress) event of either oBackup or oRestore objects, when either of them is in the process of operation.

The following are the hard-coded constants used as main parameters:

Const _INSTANCE As String = "."
Const _USER As String = "sa"
Const _PWD As String = ""
Const _BACKUPFILE As String = "c:NorthwindBackup.bkp"
Const _DATABASE As String = "Northwind"

_INSTANCE specifies instance name (in this context localhost).  _USER specifies the userid to logon to instance with the respective password specified using _PWD.  The entire backup is taken into an incremental backup file (every backup gets added to an already existing backup, but within that same file) specified using _BACKUPFILE.  The restore process gets the latest backup within the same backup file.  The backup and restore operations work on the database specified with _DATABASE.

The following is the code to work with the Backup process using SQL-DMO:

Private Sub doBackup()
        With oBackup
            '.Devices = "[NorthwindBackup]"
            .Files = _BACKUPFILE
            .Database = _DATABASE
            .BackupSetName = "MyNorthwindBkp"
            .BackupSetDescription = "Backup from VB.NET application"
            oSQLServer.Connect(_INSTANCE, _USER, _PWD)
            .SQLBackup(oSQLServer)
            oSQLServer.DisConnect()
        End With
        MessageBox.Show("Backup Completed Sucessfully", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information)
    End Sub

I hope the steps are very simple.  Specify the Backup file name, database name, backup set name, and some description. Connect using oSQLServer object; take the backup using the SQLBackup method of
oBackup object by using the connection at oSQLServer object. Similarly, we can have the code for Restore process as follows:

Private Sub doRestore()
        With oRestore
            '.Devices = "[NorthwindBackup]"
            .Files = _BACKUPFILE
            .Database = _DATABASE
            .ReplaceDatabase = True
            oSQLServer.Connect(_INSTANCE, _USER, _PWD)
            .SQLRestore(oSQLServer)
            oSQLServer.DisConnect()
        End With
        MessageBox.Show("Restore Completed Successfully", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information)
    End Sub

NOTE: Make sure you close the SQL Server Enterprise Manager before operating the Restore process, as it maintains an exclusive connection to the database.  If you drop the existing database and try to restore it, you have no need to close it.

Monday, April 04, 2011

Saturday, April 02, 2011

Code For Shopping Cart


'----------------------------------------------------------------
' Sub UpdateButton_click:
'   Update the quantity of item(s) in the shopping cart and then display the contents 
'     of the cart
' Parameters:
'   [in] sender: not used
'   [in] e: not used
'----------------------------------------------------------------
Private Sub UpdateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    Dim cartHasItems As Boolean  'Set if the cart contains items
    Dim i As Integer      'loop index
    Dim quantityString as String 'used for conversion checks
    Dim quantity as Integer 'used to set the items updated quanity
    Dim item As DataGridItem    'used to access the individual grid items
    Dim quantityTextBox As TextBox  'used to access the individual TextBoxes
    Dim row As DataRow 'used to access the individual DataRows

    With ShoppingCart(False)
        If Not .IsEmpty Then
            
            If Not Page.IsValid Then 
                Return
            End If
        
            '
            ' Validators have run so we can assume valid input
            '
            
            '
            ' reset the quanities for all the items in cart
            '
            For i = 0 To CartItemsDataGrid.Items.Count - 1
                item = CartItemsDataGrid.Items(i)
                quantityTextBox = CType(Item.FindControl("QuantityTextBox"), TextBox)
                quantityString = quantityTextBox.Text
                quantity = CInt(quantityString)
                row = .OrderItems.Rows(i)
                'update the quantity
                row(1) = quantity
            Next i
            
            .UpdateItems()
            
            cartHasItems = Not .IsEmpty
            If cartHasItems Then
                'Bind the DataGrid to the items
                CartItemsDataGrid.DataSource = CType(.OrderItems.DefaultView, System.Collections.ICollection)
                CartItemsDataGrid.DataBind
            End If                    
        End If
    End With
    
    '
    ' Set visibility of displayed items to correspond to
    '   whether or not we have items in the cart.
    '
    ShoppingCartPanel.Visible = cartHasItems
    CartItemsDataGrid.Visible = cartHasItems
    CheckOutHyperLink.Visible= cartHasItems
    EmptyCartLabel.Visible = Not cartHasItems
End Sub    

'----------------------------------------------------------------
' Sub UpdateItems:
'   Updates the Items in the shopping cart
'----------------------------------------------------------------
Public Sub UpdateItems()
    Dim row As DataRow  'used to access the individual rows in OrderItems
    Dim quantity As Integer
    Dim itemCount As Integer = OrderItems.Rows.Count
    Dim i As Integer = 0
    
    
    Do While ( i < itemCount)
        With OrderItems.Rows(i)
            quantity = CInt(.Item(OrderData.QUANTITY_FIELD))
            if quantity < 1 Then 
                .Delete
                itemCount = itemCount - 1 
            Else
                .Item(OrderData.EXTENDED_FIELD) = New Decimal(quantity  * CType(.Item(OrderData.PRICE_FIELD), Decimal))
                i = i + 1
            End If
        End With
    Loop 
End Sub

Show Image From Database On ASPX Page

 <ItemTemplate>
 <asp:Image ID="myImage" Runat="Server" ImageUrl='myBLObHandler.aspx?id=<%#Container.DataItem("myImageIdentifier") %>' />
 </ItemTemplate>




OR


 <ItemTemplate>
 <asp:Image ID="myImage" Runat="Server"  ImageUrl='<%#Container.DataItem("myImageIdentifier") %>' />
 </ItemTemplate>

Friday, April 01, 2011

Get Mouse Position in Windows Appllication


Public Class Form1 Inherits System.Windows.Forms.Form
'Windows Form Designer Generated Code
Private Sub Form1_Mousedown(ByVal sender As System.Object, ByVal e As _
System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
If e.Button = MouseButtons.Left Then
TextBox1.Text = "Mouse down at" + CStr(e.X) + " :" + CStr(e.Y)
'displaying the coordinates in TextBox1 when the mouse is pressed on the form
End If
End Sub


Private Sub Form1_MouseEnter(ByVal sender As System.Object, ByVal e_
As System.EventArgs) Handles MyBase.MouseEnter
TextBox2.Text = "Mouse Entered"
'displaying "mouse entered" in TextBox2 when the mouse pointer enters the form
End Sub


Private Sub Form1_MouseLeave(ByVal sender As System.Object, ByVal e_
As System.EventArgs) Handles MyBase.MouseLeave
TextBox3.Text = "Mouse Exited"
'displaying "mouse exited" in Textbox3 when the mouse pointer leaves the form
End Sub


End Class 

Why VB.NET


Visual Basic .NET

Visual Basic .NET provides the easiest, most productive language and tool for rapidly building Windows and Web applications. Visual Basic .NET comes with enhanced visual designers, increased application performance, and a powerful integrated development environment (IDE). It also supports creation of applications for wireless, Internet-enabled hand-held devices. The following are the features of Visual Basic .NET with .NET Framework and Visual Basic .NET . This also answers why should I use Visual Basic .NET, what can I do with it?

Powerful Windows-based Applications

Visual Basic .NET comes with features such as a powerful new forms designer, an in-place menu editor, and automatic control anchoring and docking. Visual Basic .NET delivers new productivity features for building more robust applications easily and quickly. With an improved integrated development environment (IDE) and a significantly reduced startup time, Visual Basic .NET offers fast, automatic formatting of code as you type, improved IntelliSense, an enhanced object browser and XML designer, and much more.

Building Web-based Applications

With Visual Basic .NET we can create Web applications using the shared Web Forms Designer and the familiar "drag and drop" feature. You can double-click and write code to respond to events. Visual Basic .NET comes with an enhanced HTML Editor for working with complex Web pages. We can also use IntelliSense technology and tag completion, or choose the WYSIWYG editor for visual authoring of interactive Web applications.

Simplified Deployment

With Visual Basic .NET we can build applications more rapidly and deploy and maintain them with efficiency. Visual Basic .NET and .NET Framework 1.1 makes "DLL Hell" a thing of the past. Side-by-side versioning enables multiple versions of the same component to live safely on the same machine so that applications can use a specific version of a component. XCOPY-deployment and Web auto-download of Windows-based applications combine the simplicity of Web page deployment and maintenance with the power of rich, responsive Windows-based applications.

Powerful, Flexible, Simplified Data Access

You can tackle any data access scenario easily with ADO.NET and ADO data access. The flexibility of ADO.NET enables data binding to any database, as well as classes, collections, and arrays, and provides true XML representation of data. Seamless access to ADO enables simple data access for connected data binding scenarios. Using ADO.NET, Visual Basic .NET can gain high-speed access to MS SQL Server, Oracle, DB2, Microsoft Access, and more.

Improved Coding

You can code faster and more effectively. A multitude of enhancements to the code editor, including enhanced IntelliSense, smart listing of code for greater readability and a background compiler for real-time notification of syntax errors transforms into a rapid application development (RAD) coding machine.

Direct Access to the Platform

Visual Basic developers can have full access to the capabilities available in .NET Framework. Developers can easily program system services including the event log, performance counters and file system. The new Windows Service project template enables to build real Microsoft Windows NT Services. Programming against Windows Services and creating new Windows Services is not available in Visual Basic .NET Standard, it requires Visual Studio Professional, or higher.

Full Object-Oriented Constructs

You can create reusable, enterprise-class code using full object-oriented constructs. Language features include full implementation inheritance, encapsulation, and polymorphism. Structured exception handling provides a global error handler and eliminates spaghetti code.

XML Web Services

XML Web services enable you to call components running on any platform using open Internet protocols. Working with XML Web services is easier where enhancements simplify the discovery and consumption of XML Web services that are located within any firewall. XML Web services can be built as easily as you would build any class in Visual Basic 6.0. The XML Web service project template builds all underlying Web service infrastructure.

Mobile Applications

Visual Basic .NET and the .NET Framework offer integrated support for developing mobile Web applications for more than 200 Internet-enabled mobile devices. These new features give developers a single, mobile Web interface and programming model to support a broad range of Web devices, including WML  for WAP—enabled cellular phones, compact HTML (cHTML) for i-Mode phones, and HTML for Pocket PC, handheld devices, and pagers. Please note, Pocket PC programming is not available in Visual Basic.NET Standard, it requires Visual Studio Professional, or higher.

COM Interoperability

You can maintain your existing code without the need to recode. COM interoperability enables you to leverage your existing codeassets and offers seamless bi-directional communication between Visual Basic 6.0 and Visual Basic .NET applications.

Reuse Existing Investments

You can reuse all your existing ActiveX Controls. Windows Forms in Visual Basic .NET provide a robust container for existing ActiveX controls. In addition, full support for existing ADO code and data binding enable a smooth transition to Visual Basic .NET.

Upgrade Wizard

You upgrade your code to receive all of the benefits of Visual Basic .NET. The Visual Basic .NET Upgrade Wizard, available inVisual Basic .NET  Standard Edition, and higher, upgrades up to 95 percent of existing Visual Basic code and forms to Visual Basic.NET with new support for Web classes and UserControls.