Kr0vshenk0v
High-Ticket Closer
2
MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1
200 XP
This time, I will show you how to save data in the database using Visual Basic 2008 and SQL Server 2005 Express Edition. Using this method, the data will be saved in the database and It will also display the data that you have been saved in the database to the Datagridview. See the step by step procedure below.
Let's Begin:
Step 1. Create a database in the SQL Server 2005 Express Edition and name it "userdb".
Step 2. Open Visual Basic 2008 and create a new windows form application. After that, Do the form just like this.
Step 3. Go to the code editior and declare all the classes that are needed.
Reminder: Put "using System.Data.SqlClient;" above the namespace to access sql server library.
Step 4. Go back to the design view, double-click the form and establish a connection between SQL Server 2005 Express Edition and Visual Basic 2008.
Step 5. Create a method for saving the data in the SQL Server Database.
Step 6. Go back to the design view, double-click a "Save" button and call the sub procedure
that you have created in the method.
For all students who need a programmer for your thesis system or anyone who needs a source code in any programming languages. You can contact me @ :
Email – [email protected]
Mobile No. – 09305235027 – TNT
Download
Let's Begin:
Step 1. Create a database in the SQL Server 2005 Express Edition and name it "userdb".
Step 2. Open Visual Basic 2008 and create a new windows form application. After that, Do the form just like this.

Step 3. Go to the code editior and declare all the classes that are needed.
Reminder: Put "using System.Data.SqlClient;" above the namespace to access sql server library.
- Dim
con As
SqlConnection =
New
SqlConnection(
)
- Dim
cmd As
SqlCommand
Step 4. Go back to the design view, double-click the form and establish a connection between SQL Server 2005 Express Edition and Visual Basic 2008.
- Private
Sub
Form1_Load(
ByVal
sender As
System.
Object
, ByVal
e As
System.
EventArgs
)
Handles
MyBase
.
Load
- con.
ConnectionString
=
"Data Source=.\SQLEXPRESS;Database=userdb;trusted_connection=true;"
- End
Sub
Step 5. Create a method for saving the data in the SQL Server Database.
- Private
Sub
SaveData(
ByVal
sql As
String
)
- Try
- con.
Open
(
)
- If
con.
State
=
ConnectionState.
Open
Then
- Dim
result As
Integer
- cmd =
New
SqlCommand
- With
cmd
- .
Connection
=
con
- .
CommandText
=
sql
- result =
.
ExecuteNonQuery
- End
With
- If
result >
0
Then
- MsgBox
(
"Data has been saved in the database."
)
- End
If
- End
If
- Catch
ex As
Exception
- MsgBox
(
ex.
Message
)
- Finally
- con.
Close
(
)
- End
Try
- End
Sub
Step 6. Go back to the design view, double-click a "Save" button and call the sub procedure
that you have created in the method.
- Private
Sub
btnSave_Click(
ByVal
sender As
System.
Object
, ByVal
e As
System.
EventArgs
)
Handles
btnSave.
Click
- Dim
sql As
String
=
"INSERT INTO tbluser (NAME,UNAME,PASS,UTYPE) VALUES ('"
&
txtName.
Text
&
"','"
&
txtUsername.
Text
&
"','"
&
txtPassword.
Text
&
"','"
&
cboUtype.
Text
&
"')"
- SaveData(
sql)
- End
Sub
For all students who need a programmer for your thesis system or anyone who needs a source code in any programming languages. You can contact me @ :
Email – [email protected]
Mobile No. – 09305235027 – TNT
Download
You must upgrade your account or reply in the thread to view the hidden content.