Hi there.
I'm new to ADO.NET, and I'm trying to learn this without having to bother you lot on simple questions

But..
I'm having just a tiny problem with updating the SQL database. I'm trying to update 2 fields on a table "MatterDesc" and ModifiedDate". "MatterDesc" updates fine, "ModifiedDate" won't update. I think the problem is with the SQLParameter (highlighted in red in the code below).

VB Code:
  1. Imports System.Data.SqlClient
  2.  
  3. Public Class frmPIMatter
  4.     Inherits System.Windows.Forms.Form
  5.  
  6.     Dim connCaseMan As SqlConnection = New SqlConnection("Data Source=BIRMDATA;Initial Catalog=CaseMan;Integrated Security=SSPI")
  7.     Dim cmdSelect As New SqlCommand()
  8.     Dim cmdUpdateMatter As New SqlCommand()
  9.     Dim cmdDelete As New SqlCommand()
  10.     Dim prmMatter As SqlParameter
  11.     Dim daMatter As New SqlDataAdapter()
  12.     Dim dsMatter As New DataSet()
  13.  
  14. #Region " Windows Form Designer generated code "
  15. ...
  16. #End Region
  17.  
  18.     Private Sub frmPIMatter_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  19.  
  20.         Dim sSQL As String
  21.  
  22.         'Set up SQL parameters
  23.         'UPDATE Matter
  24.         sSQL = "UPDATE Matter SET "
  25.         sSQL = sSQL & "MatterDesc = @MatterDesc, "
  26.         sSQL = sSQL & "ModifiedDate = @ModifiedDate "
  27.         sSQL = sSQL & "WHERE MatterID = " & Me.Tag
  28.         cmdUpdateMatter = connCaseMan.CreateCommand
  29.         cmdUpdateMatter.CommandText() = sSQL
  30.         prmMatter = cmdUpdateMatter.Parameters.Add("@MatterDesc", SqlDbType.VarChar, 50, "MatterDesc")
  31.         [color=red]prmMatter = cmdUpdateMatter.Parameters.Add("@ModifiedDate", SqlDbType.DateTime, 8, "ModifiedDate")[/color]
  32.         prmMatter.SourceVersion = DataRowVersion.Original
  33.         daMatter.UpdateCommand = cmdUpdateMatter
  34.  
  35.         'SELECT
  36.         sSQL = "SELECT Matter.MatterDesc, "
  37.         sSQL = sSQL & "Matter.OpenDate, "
  38.         sSQL = sSQL & "Matter.ModifiedDate "
  39.         sSQL = sSQL & "FROM Matter "
  40.         sSQL = sSQL & "WHERE Matter.MatterID = " & Me.Tag
  41.  
  42.         cmdSelect = connCaseMan.CreateCommand
  43.         cmdSelect.CommandText = sSQL
  44.         daMatter.SelectCommand = cmdSelect
  45.         daMatter.Fill(dsMatter, "Matter")
  46.  
  47.         With Me
  48.             .Text = dsMatter.Tables(0).Rows(0).Item(0) & " [" & Format(.Tag, "000000") & "]"
  49.             .lblOpenDate.Text() = Format(dsMatter.Tables(0).Rows(0).Item(1), "ddd dd/MM/yyyy")
  50.             .txtMatterDesc.DataBindings.Add("Text", dsMatter.Tables(0), "MatterDesc")
  51.             .lblModifiedDate.DataBindings.Add("Text", dsMatter.Tables(0), "ModifiedDate") 'Displays OK when form has loaded - so is reading it OK from the database.
  52.         End With
  53.  
  54.     End Sub
  55.  
  56.     Private Sub frmPIMatter_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed
  57.  
  58.         connCaseMan.Close()
  59.         cmdSelect.Dispose()
  60.         daMatter.Dispose()
  61.         dsMatter.Dispose()
  62.  
  63.     End Sub
  64.  
  65.     Private Sub tbPIMatter_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles tbPIMatter.ButtonClick
  66.  
  67.         Me.lblModifiedDate.Text = Format(Now, "dd/MM/yyyy HH:mm:ss")
  68.  
  69.         Me.BindingContext(dsMatter.Tables(0)).EndCurrentEdit()
  70.         daMatter.Update(dsMatter, "Matter")
  71.  
  72.         RefreshMatters(ctrlActiveScreen)
  73.  
  74.         Me.Close()
  75.  
  76.     End Sub
  77.  
  78. End Class

Thanks for any help