ช่วยทีครับ ID ผมไม่ยอมหมุน มันนับได้แค่ 1กับ2 แล้วมันก็ค้าง 2 ไปเรื่อยๆๆๆๆ ได้ประมานนี้ครับ
ID Name Address
1 xxxx xxxxxx
2 xxxx xxxxxx
2 xxxx xxxxx
2 xxxxx xxxxx
2 xxxxx xxxxxx
นี้คือโคดครับ ผมใช้ ASP.net , sql server 2000
Sub PostNews(Sender As Object,E As EventArgs)
Dim strconn As String = "Provider=SQLOLEDB;server=(local);database=WEBNEW;uid=sa;pwd=123456"
Dim strsql As String = "Select * From News"
Dim myconn As New OleDbConnection(strconn)
Dim myda As New OleDbDataAdapter(strsql,myconn)
Dim ds As New DataSet()
Dim oCB As New OleDbCommandBuilder(myda)
myda.Fill(ds,"UpNews")
Dim oDR As DataRow = ds.Tables("UpNews").NewRow()
If ds.Tables("UpNews").Rows.Count = 0 Then
oDR.Item("ID") = 1
Else
oDR.Item("ID") = ds.Tables("UpNews").Rows(0).Item("ID") + 1
End If
oDR.Item("NewsLine") = NewsLine.Text
oDR.Item("INFOR") = note.Text
oDR.Item("URL") = "ShowNews.aspx"
oDR.Item("NAME") = name.Text
oDR.Item("DATE_") = Now()
oDR.Item("EMAIL_") = email.Text
ds.Tables("UpNews").Rows.Add(oDR)
myda.Update(ds,"UpNews")
Dim myCommand As New OleDbCommand(strsql, myconn)
myCommand.Connection.Open()
myCommand.ExecuteNonQuery()
myconn.Close()
Response.Redirect("ShowNews.aspx")
End Sub