0% found this document useful (0 votes)
38 views

Conn

This code defines a web form class with methods to clear textbox fields and submit form data to a SQL database. When the clear button is clicked, it empties the values of five textbox controls. When the submit button is clicked, it opens a SQL connection, builds an INSERT statement to add the textbox values to a "candidate" table, executes the non-query command, and closes the connection.

Uploaded by

api-3806091
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

Conn

This code defines a web form class with methods to clear textbox fields and submit form data to a SQL database. When the clear button is clicked, it empties the values of five textbox controls. When the submit button is clicked, it opens a SQL connection, builds an INSERT statement to add the textbox values to a "candidate" table, executes the non-query command, and closes the connection.

Uploaded by

api-3806091
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

Imports System.Data.

SqlClient

Partial Public Class WebForm23


Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As


System.EventArgs) Handles Me.Load

End Sub

Protected Sub btnclear_Click(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles btnclear.Click
txtfirstname.Text = " "
txtmiddlename.Text = " "
txtlastname.Text = " "
txtaddress.Text = " "
txteducation.Text = " "
End Sub

Private Sub btnsubmit_Click(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles btnsubmit.Click
Dim con As New System.Data.SqlClient.SqlConnection

Dim SQLstrng As String


con.ConnectionString = "Password=dbserversql;Persist Security
Info=True;User ID=sa;Initial Catalog=Northwind;Data Source=DBSERVER"
con.Open()
SQLstrng = "insert into candidate values('" & txtfirstname.Text
& "' , '" & txtmiddlename.Text & "','" & txtlastname.Text & "','" &
txtaddress.Text & "','" & txteducation.Text & "')"

Dim Cmd As New System.Data.SqlClient.SqlCommand(SQLstrng, con)


'Cmd.CommandText = SQLstrng
Cmd.CommandType = CommandType.Text
'con.Open()
Cmd.ExecuteNonQuery()

con.Close()
End Sub
End Class

You might also like