0% found this document useful (0 votes)
52 views1 page

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)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views1 page

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)
We take content rights seriously. If you suspect this is your content, claim it here.
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

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy