Tutorials
Resources
Forum
Reviews
Communities
Interview
Jobs
Projects
Training
Your
Ad
Here
Silverlight Games
|
Mentor
|
Code Converter
|
Articles
|
Code Factory
|
Computer Jokes
|
Members
|
Peer Appraisal
|
IT Companies
|
Bookmarks
|
Polls
|
Revenue Sharing
|
Lobby
|
Gift Shop
|
Prizes & Awards
My Profile
Sign In
Register
AdSense Revenue
Active Members
Today
Alwyn
(200)
Asheej T K
(106)
Avinash Mohan
(90)
Last 7 Days
Alwyn
(938)
Asheej T K
(529)
nishithraj
(525)
more...
Resources
»
Code Snippets
»
SQL
»
Accessing SQL Server in VB.NET
Posted Date: 19 Nov 2008
Resource Type:
Code Snippets
Category:
SQL
Author:
mahendrakiran
Member Level:
Gold
Rating:
Points
: 7
Imports System.Data.SqlClient
Public Class Form1 Inherits System.Windows.Forms.Form
Dim myConnection As SqlConnection
Dim myCommand As SqlCommand
Dim dr As New SqlDataReader()
'declaring the objects need
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As_
System.EventArgs) Handles MyBase.Load
myConnection = New
SqlConnection("server=localhost;uid=sa;pwd=;database=pubs")
'establishing connection
Try
myConnection.Open()
'opening the connection
myCommand = New SqlCommand("Select * from discounts", myConnection)
'executing the command and assigning it to connection
dr = myCommand.ExecuteReader()
While dr.Read()
'reading from the datareader
MessageBox.Show("discounttype" & dr(0).ToString())
MessageBox.Show("stor_id" & dr(1).ToString())
MessageBox.Show("lowqty" & dr(2).ToString())
MessageBox.Show("highqty" & dr(3).ToString())
MessageBox.Show("discount" & dr(4).ToString())
'displaying the data from the table
End While
dr.Close()
myConnection.Close()
Catch e As Exception
End Try
End Sub
End Class
Responses
No responses found. Be the first to respond and make money from
revenue sharing program
.
Feedbacks
Popular Tags
What are tags ?
Search Tags
Sign In
to add tags.
(No tags found.)
Post Feedback
This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must
Sign In
to post a response.
Next Resource:
Begin tran in Stored Procedure
Previous Resource:
Returning String Instead of NULL
Return to Discussion Resource Index
Post New Resource
Category:
SQL
Post resources and
earn money
!
More Resources
Begin tran in Stored Procedure
Generate Bill Number with year prefix
Trigger for calculation of table activity
Triggers deleting duplicate rows using T-sql Programming
How to rename the column in SQL server using stored procedure
Stored Procedures
dotNet Slackers
About Us
Contact Us
Privacy Policy
Terms Of Use