Coding
Coding
</asp:Content>
Imports System.Data.SqlClient
End Sub
End Class
Imports System.Data
Imports System.Data.SqlClient
Partial Class student
Inherits System.Web.UI.Page
Dim con As New SqlConnection("Data Source=.\sqlexpress;Initial
Catalog=ayyappa;Integrated Security=True")
drpcategory.Items.Clear()
While rs.Read()
drpcategory.Items.Add(rs(1).ToString())
' rs.MoveNext()
End While
End Sub
Sub loadid()
conn.Close()
conn.Open()
Dim i As Integer
sql = "select max(p_id) from tbl_student"
Dim cmd As New SqlCommand
cmd = New SqlCommand(sql, conn)
rs = cmd.ExecuteReader()
If rs.Read() Then
Try
i = Convert.ToInt32(rs(0).ToString())
Catch ex As Exception
i=0
End Try
i=i+1
txtid.Text = i
Else
i=1
txtid.Text = i
End If
End Sub
Sub clear()
drpcategory.SelectedIndex = 0
txtdepartment.Text = ""
txtcolor.Text = ""
txtdesc.Text = ""
txtamount.Text = ""
txtquan.Text = ""
txtid.Text = ""
End Sub
Sub loadgrid()
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
opendb()
If Session("usertype") = "Admin" Then
loadcat()
loadid()
loadgrid()
Else
Response.Redirect("frmviewstudents.aspx")
End If
End Sub
End Try
End If
End Sub
image = a_pic.ImageUrl
sql = "insert into
tbl_student(p_id,p_cat,p_department,p_color,p_desc,p_amount,p_quantity,p_imag
e)"
sql = sql & "values('" & txtid.Text & "','" & drpcategory.Text & "','" &
txtdepartment.Text & "','" & txtcolor.Text & "','" & txtdesc.Text & "','" &
txtamount.Text & "','" & txtquan.Text & "','" & image & "')"
Dim cmd As New SqlCommand
cmd = New SqlCommand(sql, conn)
cmd.ExecuteNonQuery()
'conn.Execute(sql)
Label.Text = "student added"
clear()
loadid()
loadgrid()
End Sub
End Class