Hejsan!
Jag har en sida där olika notiser visas med en rubrik och sen texten till notisen, detta hämtas från en MS SQL DB.
Just nu lagras ju alla notiser i DB, men jag skulle vilja att bara 3 notiser finns i DB och att sen när man skriver in en ny notis så skriver den över en av de gamla.
Hur kan jag lösa det, hur skriver jag det i koden?
mvh Sanne
Så här ser min kod ut nu:
<script runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
Dim myConnection As SqlConnection
Dim myCommand As SqlDataAdapter
' Create a connection to the "pubs" SQL database located on the
' local computer.
myConnection = New SqlConnection("server=xxxxx;UID=xxxx;PWD=xxxx;Initial Catalog=xxx;")
' Connect to the SQL database using a SQL SELECT query to get all
' the data from the "notistabell" table.
myCommand = New SqlDataAdapter("SELECT * FROM notiser ORDER BY ID Desc", myConnection)
' Create and fill a DataSet.
Dim ds As DataSet = new DataSet()
myCommand.Fill(ds)
' Bind MyDataList to the DataSet. MyDataList is the ID for
' the DataList control in the HTML section of the page.
MyDataList.DataSource = ds
MyDataList.DataBind()
End Sub
</script>