Hi Friends
I have designed a form with 2 label boxes, 2 text boxes & 1 command button. If I click the command button then, the value entered in the text boxes should be inserted in the db & at the same time it should display in the grid view. The platform is ASP.NET with SQL SERVER 2000.
The coding I have given is
[code=vbnet]
Imports System.Data
Imports System.Data.Sql Client
'------------------------------------------------------------------------------------
Dim con As SqlConnection
Dim cmd As SqlCommand
Dim dgcmd As SqlCommand
Dim str, str1 As String
Dim dgstr As String
Dim da As SqlDataAdapter
Dim ds As DataSet
'------------------------------------------------------------------------------------
Protected Sub Button4_Click(B yVal sender As Object, ByVal e As System.EventArg s) Handles Button4.Click
str = "user id=sa;password= ;data source=AURO-RA4;initial catalog=suganya ;server=AURO-RA4"
con = New SqlConnection(s tr)
Try
con.Open()
Catch
End Try
str1 = "Insert into theater values('" & TextBox1.Text & "','" & TextBox2.Text & "')"
cmd = New SqlCommand(str1 , con)
cmd.ExecuteNonQ uery()
con.Close()
Response.Write( "Inserted")
dgstr = "select * from theater"
dgcmd = New SqlCommand(dgst r, con)
da = New SqlDataAdapter( dgstr, con)
ds = New DataSet()
da.Fill(ds)
GridView1.DataS ource = ds
GridView1.DataB ind()
End Sub
[/code]
Here the records are getting inserted but the GridView1 is not getting visible while running. There is also no error
I have designed a form with 2 label boxes, 2 text boxes & 1 command button. If I click the command button then, the value entered in the text boxes should be inserted in the db & at the same time it should display in the grid view. The platform is ASP.NET with SQL SERVER 2000.
The coding I have given is
[code=vbnet]
Imports System.Data
Imports System.Data.Sql Client
'------------------------------------------------------------------------------------
Dim con As SqlConnection
Dim cmd As SqlCommand
Dim dgcmd As SqlCommand
Dim str, str1 As String
Dim dgstr As String
Dim da As SqlDataAdapter
Dim ds As DataSet
'------------------------------------------------------------------------------------
Protected Sub Button4_Click(B yVal sender As Object, ByVal e As System.EventArg s) Handles Button4.Click
str = "user id=sa;password= ;data source=AURO-RA4;initial catalog=suganya ;server=AURO-RA4"
con = New SqlConnection(s tr)
Try
con.Open()
Catch
End Try
str1 = "Insert into theater values('" & TextBox1.Text & "','" & TextBox2.Text & "')"
cmd = New SqlCommand(str1 , con)
cmd.ExecuteNonQ uery()
con.Close()
Response.Write( "Inserted")
dgstr = "select * from theater"
dgcmd = New SqlCommand(dgst r, con)
da = New SqlDataAdapter( dgstr, con)
ds = New DataSet()
da.Fill(ds)
GridView1.DataS ource = ds
GridView1.DataB ind()
End Sub
[/code]
Here the records are getting inserted but the GridView1 is not getting visible while running. There is also no error
Comment