detail code for sql data connections?

Answer Posted / bhagwat prasad sharma

Steps: SqlConnection with vb.net code
'' Code

imports system.data.sqlclients
Public Class Form1 Inherits System.Windows.Forms.Form
'' createconnection with database

dim con as new sqlconnection("server=bps; database=company; user id=sa; password=admin")

private sub button1_click()

dim str as string="insert into employee (roll_no,name,class) values(@roll_no,@name,@class)"

dim cmd as new sqlcommand =(str,con)

if con.state=connectionstate.closed than
con.open()
'' parameter passing

cmd.parameters.add("@roll_no",type.int)
cmd.parameters.add("@name",type.varchar)
cmd.parameters.add("@class",type.varchar)

cmd.parameters("@roll_no").value= txtroll.text
cmd.parameters("@name").value=txtname.text
cmd.parameters("@class").value= txtclass.text

dim i as integer
i=cmd.executeNonquery

if i>o
msgbox("addition successful")
else
msgbox("sum mistakes into add")
end if
' end of connection
con.close()
end sub
end class

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is difference between Lambda Expression and LINQ in ASP.NET?

540


What is a global postback url?

511


What is asp.net futures?

569


Difference between web user control and web custom control?

502


Is oauth for authentication or authorization?

585






Explain the difference between asp and asp.net?

508


Explain swagger components.

563


What is server side session?

518


How you can return View from ASP.NET Web API method?

543


What are the types of authentication in asp.net?

549


Are xaml file compiled or built on runtime?

553


Explain the difference between page.registerclientscriptblock and page.registerstartupscript?

568


What is session mode in asp.net?

517


Explain the difference between globalization and localization techniques

528


Where would you use an ihttpmodule, and what are the limitations of any?

547