This is also a sample code - try this too |
| santhosh kumar replied to rana pranav at 03-Jul-08 07:01 |
Hi,
Check this out ;-
Public strConn As String = "data source=xx.xx.xxx.xxx; User ID=xxxxxx; Password=xxxxxx;
Persist Security Info=True;packet size=4096"
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
If Not Page.IsPostBack Then
LoadData()
End If
End Sub
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnDelete.Click
Dim cmd As New SqlCommand("DELETE FROM Customers WHERE FirstName = '" &
txtFirstName.Text & "'", New SqlConnection(strConn))
cmd.Connection.Open()
cmd.ExecuteNonQuery()
cmd.Connection.Close()
LoadData()
End Sub
Sub LoadData()
Dim strSQL As String = "Select * From Customers"
Dim cmd As New SqlCommand(strSQL, New SqlConnection(strConn))
cmd.Connection.Open()
Repeater1.DataSource = cmd.ExecuteReader
Repeater1.DataBind()
cmd.Connection.Close()
cmd.Connection.Dispose()
End Sub
End Class
Regards, Santhosh
|
|