if you want more related search please click here
please help to other
http://scriptquery.blogspot.in/
<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: 14px; white-space: pre-wrap;">how to update, search, delete, clear, insert
---------------------------------------------
Imports System
Imports System.Data
Imports System.Data.SqlClient
Partial Class viewer
Inherits System.Web.UI.Page
Dim con As New SqlConnection()
Dim cmd As New SqlCommand()
Dim dt As New DataTable()
Dim da As New SqlDataAdapter
Dim connectionstring As String = "server=systemname;database=practice;User ID =sa; password=123;integrated security=false"
#Region "btninsert"
Protected Sub btninsert_Click(sender As Object, e As System.EventArgs) Handles btninsert.Click
con = New SqlConnection(connectionstring)
con.Open()
cmd.CommandText = "employee_details" ' insert
cmd.CommandType = CommandType.StoredProcedure
Try
cmd.Parameters.AddWithValue("@empname", txtempname.Text)
cmd.Parameters.AddWithValue("@empno", txtempno.Text)
cmd.Parameters.AddWithValue("@empphoneno", txtempphno.Text)
cmd.Parameters.AddWithValue("@empdesignation", txtdesignation.Text)
cmd.Connection = con
cmd.ExecuteNonQuery()
con.Close()
clearcontrols()
ScriptManager.RegisterStartupScript(Me, [GetType](), "showalert", "alert('Record Inserted sucessfully...');", True)
Catch ex As Exception
End Try
End Sub
#End Region
#Region "btnupdate"
Protected Sub btnupdate_Click(sender As Object, e As System.EventArgs) Handles btnupdate.Click
con = New SqlConnection(connectionstring)
con.Open()
cmd.CommandText = "employee_update"
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@empname", txtempname.Text)
cmd.Parameters.AddWithValue("@empno", txtempno.Text)
cmd.Parameters.AddWithValue("@empphoneno", txtempphno.Text)
cmd.Parameters.AddWithValue("@empdesignation", txtdesignation.Text)
cmd.Connection = con
cmd.ExecuteNonQuery()
con.Close()
clearcontrols()
ScriptManager.RegisterStartupScript(Me, [GetType](), "showalert", "alert('Record Updated sucessfully...');", True)
End Sub
#End Region
#Region "btnsearch"
Protected Sub btnsearch_Click(sender As Object, e As System.EventArgs) Handles btnsearch.Click
If txtempno.Text <> "" Then
Dim empty As Boolean = search(txtempno.Text)
If empty = False Then
ScriptManager.RegisterStartupScript(Me, [GetType](), "showalert", "alert('Invalid employee-Code');", True)
clearcontrols()
End If
Else
ScriptManager.RegisterStartupScript(Me, [GetType](), "showalert", "alert('Please enter employee-Code');", True)
End If
txtempno.Focus()
End Sub
#End Region
#Region "search"
Public Function search(ByVal asstcodes As String) As Boolean
con = New SqlConnection(connectionstring)
cmd.CommandText = "Select empname,empno,empphoneno,empdesignation from employee where empno =@empno"
cmd.Parameters.AddWithValue("@empno", txtempno.Text)
cmd.CommandType = CommandType.Text
cmd.Connection = con
con.Open()
Dim dr As SqlDataReader = cmd.ExecuteReader()
While dr.Read
txtempname.Text = dr("empname").ToString()
txtempno.Text = dr("empno").ToString()
txtempphno.Text = dr("empphoneno").ToString()
txtdesignation.Text = dr("empdesignation").ToString()
con.Close()
Return True
End While
con.Close()
Return False
End Function
#End Region
#Region "clear controls"
Public Sub clearcontrols()
txtempname.Text = Nothing
txtempno.Text = Nothing
txtempphno.Text = Nothing
txtdesignation.Text = Nothing
End Sub
#End Region
Protected Sub btnclear_Click(sender As Object, e As System.EventArgs) Handles btnclear.Click
clearcontrols()
End Sub
Protected Sub btndelete_Click(sender As Object, e As System.EventArgs) Handles btndelete.Click
con = New SqlConnection(connectionstring)
con.Open()
cmd.CommandText = "employee_delete"
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@empno", txtempno.Text)
cmd.Connection = con
cmd.ExecuteNonQuery()
cmd.Connection = con
con.Close()
clearcontrols()
ScriptManager.RegisterStartupScript(Me, [GetType](), "showalert", "alert('Record Deleted sucessfully');", True)
End Sub
End Class
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="register.aspx.vb" Inherits="viewer" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Registration Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<center>
<fieldset style="border-style: solid; border-width: 1px; width: 50%;">
<legend><b>Registration</b></legend>
<table width="80%">
<tr>
<td style="padding-left: 120px;">
<asp:Label ID="lblempno" runat="server" Text="EMPLOYEENO: "></asp:Label>
</td>
<td>
<asp:TextBox ID="txtempno" runat="server" Width="200px" Style="text-align: left"></asp:TextBox>
</td>
</tr>
<tr>
<td style="padding-left: 120px;">
<asp:Label ID="lblempname" runat="server" Text="EMPLOYEENAME: "></asp:Label>
</td>
<td>
<asp:TextBox ID="txtempname" runat="server" Width="200px" Style="text-align: left"></asp:TextBox>
</td>
</tr>
<tr>
<td style="padding-left: 120px;">
<asp:Label ID="lblempphoneno" runat="server" Text="EMPLOYEEPHONENO: "></asp:Label>
</td>
<td>
<asp:TextBox ID="txtempphno" runat="server" Width="200px" Style="text-align: left"></asp:TextBox>
</td>
</tr>
<tr>
<td style="padding-left: 120px;">
<asp:Label ID="lbldesignation" runat="server" Text="EMPLOYEEDESIGNATION: "></asp:Label>
</td>
<td>
<asp:TextBox ID="txtdesignation" runat="server" Width="200px" Style="text-align: left"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Button ID="btninsert" runat="server" Text="Insert" Height="25px" Width="75px" />
<asp:Button ID="btnsearch" runat="server" Text="search" Height="25px" Width="75px" />
<asp:Button ID="btnupdate" runat="server" Text="Update" Height="25px" Width="75px" />
<asp:Button ID="btndelete" runat="server" Text="Delete" Height="25px" Width="75px" />
<asp:Button ID="btnclear" runat="server" Text="Clear" Height="25px" Width="75px" />
</td>
</tr>
</table>
</fieldset>
</center>
</div>
</form>
</body>
</html></span></div>
if you want more related search please click here
please help to other
http://scriptquery.blogspot.in/
11:48 PM
Share:
0 comments: