Display Records Instantly

R

RN1

A Form has a few fields & a Repeater. When the Submit button is
clicked, I want 2 things:

- the record is inserted in a database
- the Repeater should display the just inserted record (along with the
other records).

I could implement the first but not the second. This is how I tried it
(this is the OnClick event function of the Button):

-----------------------
Dim dSet As DataSet
Dim sqlCmd As SqlCommand
Dim sqlConn As SqlConnection
Dim sqlDapter As SqlDataAdapter

sqlConn = New SqlConnection("......")
sqlDapter = New SqlDataAdapter

sqlCmd = New SqlCommand("SELECT * FROM ETS ORDER BY EID", sqlConn)
sqlDapter.SelectCommand = sqlCmd

dSet = New DataSet
sqlDapter.Fill(dSet, "ETS")

sqlCmd = New SqlCommand("INSERT INTO ETS (SDateTime, EDateTime, Count,
Description) VALUES (@SDateTime, @EDateTime, @Count, @Description)",
sqlConn)
With sqlCmd
.Parameters.Add("@SDateTime", SqlDbType.DateTime).Value =
CDate(dtStart)
.Parameters.Add("@EDatetIme", SqlDbType.DateTime).Value =
CDate(dtEnd)
.Parameters.Add("@Count", SqlDbType.Int).Value = txtCount.Text
.Parameters.Add("@Description", SqlDbType.VarChar, 500).Value =
txtDesc.Text
End With

sqlDapter.InsertCommand = sqlCmd
sqlConn.Open()
sqlCmd.ExecuteNonQuery()
sqlDapter.Update(dSet.Tables("ETS"))

rptrETS.DataSource = dSet.Tables("ETS").DefaultView
rptrETS.DataBind()
-----------------------

As already said, the just inserted record is not getting reflected in
the Repeater though I am updating the DataSet.

Can someone please point out where am I erring & how can I make the
Repeater display the newly inserted record?

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top