Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Run Time Insertion Values To Database
Author:
Divya M
E-mail:
Click to e-mail author
Submitted:
1/17/2011
Version:
VB 2005
Compatibility:
VB 2005, VB 2008, VB 2010
Category:
Databases
Views:
10363
This is a simple program in vb.net 2005 to insert values while in runtime to the sql db connection code will be written through vb.net 2005 and click on execute(!) option in the sql server 2005 to display the inserted values from visual studio...
Declarations:
Steps:- ======== First, create the login information to the database and create a database and table under the same login and same server e.g. Server=USER\SQLEXPRESS; database=
; uid=
; password=
; trusted_connection=yes; these keywords are used in the program then, after creating the program in vb.net click the execute query option to run the program....
Code:
Imports System Imports System.Data Imports System.Data.SqlClient Imports System.Data.SqlClient.SqlConnection Public Class Form1 Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click Dim con As SqlConnection con = New SqlConnection("Server=USER\SQLEXPRESS;Database=divd b1;uid=divdb1;password=divya;trusted_connection=yes;") con.Open() Dim insert As SqlCommand insert = New SqlCommand("INSERT INTO divtab1 VALUES(' " & txtEmpID.Text & " ', ' " & txtEmpName.Text & " ', ' " & txtAge.Text & " ', ' " & txtSalary.Text & " ', ' " & txtJob.Text & " ')", con) insert.ExecuteNonQuery() MessageBox.Show("Employee Details Populated", "IDBI Mutual Funds") clear() End Sub Sub clear() txtEmpID.Text = " " txtEmpName.Text = " " txtAge.Text = " " txtSalary.Text = " " txtJob.Text = " " End Sub Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click End End Sub End Class Note:- this program contains the database which i have created... while downloading you have to change the server name, database name, user id, passwords and change it in the program also... then only this will execute...
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement