Click here to Skip to main content
15,914,225 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am new in VS 2010
I am using asp.net
I want to create a web form in Vs 2010 asp.net, code must be in VB

I created a connection with my local database and it is working
I put 2 text box on page and a button

Now i want when i press that button then
the first one record shows in the text box

I want a simple example
Please help me to solve this problem

Thank you
js
Posted
Comments
Philippe Mori 19-Sep-11 19:22pm    
You should take a look at ASP.NET. There are a lot of videos and tutorials. By listening videos, you will rapidely have an idea how it works. Then after that, you could do some tutorials to practice yourself.
Prerak Patel 19-Sep-11 23:44pm    
Yes, exactly. But, correct the link.

1 solution

C#
CREATE TABLE Users(
	ID int IDENTITY(1,1) NOT NULL PRIMARY KEY,
	NAME nvarchar(50) NULL,
 )
  
 INSERT INTO [Users] VALUES ('ABC')
 INSERT INTO [Users] VALUES ('DEF')
 INSERT INTO [Users] VALUES ('GHI')
 INSERT INTO [Users] VALUES ('JKL')



VB
Protected Sub btnshow_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnshow.Click
        Dim cn As SqlConnection
        vd = New SqlConnection("YOUR CONNECTION STRING")
        If cn.State = ConnectionState.Closed Then
            cn.Open()
        End If
        Dim da As SqlDataAdapter = New SqlDataAdapter()
        Dim ds As DataSet = New DataSet()
        Dim query As String = "SELECT * FROM [User]"
        'You can write your own query here as per your requirement
        da.SelectCommand = New SqlCommand(query, cn)
        da.SelectCommand.ExecuteScalar()
        ds.Clear()
        da.Fill(ds)
        txtID.Text = ds.Tables(0).Rows(0)(0).ToString()
        txtName.Text = ds.Tables(0).Rows(0)(1).ToString()
        cn.Close()


    End Sub
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900