V
Vlado Jasovic \(excelleinc.com\)
Hello,
I have a simple form with one text field binded to dataset.
for some reason when I call DA.UPDATE(DS) it's not working. I am using
stored procedures that are tested and working.
Thank you in advance
Here's the code:
Public Class frmTest
Inherits DevExpress.XtraEditors.XtraForm
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents SqlDataAdapter1 As System.Data.SqlClient.SqlDataAdapter
Friend WithEvents SqlConnection1 As System.Data.SqlClient.SqlConnection
Friend WithEvents SqlSelectCommand1 As System.Data.SqlClient.SqlCommand
Friend WithEvents SqlInsertCommand1 As System.Data.SqlClient.SqlCommand
Friend WithEvents SqlUpdateCommand1 As System.Data.SqlClient.SqlCommand
Friend WithEvents SqlDeleteCommand1 As System.Data.SqlClient.SqlCommand
Friend WithEvents DsTest1 As eXceLLe_TS.dsTest
Friend WithEvents frmFirstName As System.Windows.Forms.TextBox
Friend WithEvents btnUpdate As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.SqlDataAdapter1 = New System.Data.SqlClient.SqlDataAdapter
Me.SqlDeleteCommand1 = New System.Data.SqlClient.SqlCommand
Me.SqlConnection1 = New System.Data.SqlClient.SqlConnection
Me.SqlInsertCommand1 = New System.Data.SqlClient.SqlCommand
Me.SqlSelectCommand1 = New System.Data.SqlClient.SqlCommand
Me.SqlUpdateCommand1 = New System.Data.SqlClient.SqlCommand
Me.DsTest1 = New eXceLLe_TS.dsTest
Me.frmFirstName = New System.Windows.Forms.TextBox
Me.btnUpdate = New System.Windows.Forms.Button
CType(Me.DsTest1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'SqlDataAdapter1
'
Me.SqlDataAdapter1.DeleteCommand = Me.SqlDeleteCommand1
Me.SqlDataAdapter1.InsertCommand = Me.SqlInsertCommand1
Me.SqlDataAdapter1.SelectCommand = Me.SqlSelectCommand1
Me.SqlDataAdapter1.TableMappings.AddRange(New
System.Data.Common.DataTableMapping() {New
System.Data.Common.DataTableMapping("Table", "NewSelectCommand", New
System.Data.Common.DataColumnMapping() {New
System.Data.Common.DataColumnMapping("id", "id"), New
System.Data.Common.DataColumnMapping("firstname", "firstname")})})
Me.SqlDataAdapter1.UpdateCommand = Me.SqlUpdateCommand1
'
'SqlDeleteCommand1
'
Me.SqlDeleteCommand1.CommandText = "[NewDeleteCommand]"
Me.SqlDeleteCommand1.CommandType = System.Data.CommandType.StoredProcedure
Me.SqlDeleteCommand1.Connection = Me.SqlConnection1
Me.SqlDeleteCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@RETURN_VALUE",
System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue,
False, CType(0, Byte), CType(0, Byte), "",
System.Data.DataRowVersion.Current, Nothing))
Me.SqlDeleteCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@cboID", System.Data.SqlDbType.Int, 4,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"", System.Data.DataRowVersion.Original, Nothing))
'
'SqlConnection1
'
Me.SqlConnection1.ConnectionString = "workstation id=VLADO;packet
size=4096;user id=sa;data source=DEVSERVER;persist se" & _
"curity info=True;initial catalog=xllts;password=nothere"
'
'SqlInsertCommand1
'
Me.SqlInsertCommand1.CommandText = "[NewInsertCommand]"
Me.SqlInsertCommand1.CommandType = System.Data.CommandType.StoredProcedure
Me.SqlInsertCommand1.Connection = Me.SqlConnection1
Me.SqlInsertCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@RETURN_VALUE",
System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue,
False, CType(0, Byte), CType(0, Byte), "",
System.Data.DataRowVersion.Current, Nothing))
Me.SqlInsertCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@firstname",
System.Data.SqlDbType.VarChar, 24, "firstname"))
'
'SqlSelectCommand1
'
Me.SqlSelectCommand1.CommandText = "[NewSelectCommand]"
Me.SqlSelectCommand1.CommandType = System.Data.CommandType.StoredProcedure
Me.SqlSelectCommand1.Connection = Me.SqlConnection1
Me.SqlSelectCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@RETURN_VALUE",
System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue,
False, CType(0, Byte), CType(0, Byte), "",
System.Data.DataRowVersion.Current, Nothing))
Me.SqlSelectCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@cboID", System.Data.SqlDbType.Int, 4))
'
'SqlUpdateCommand1
'
Me.SqlUpdateCommand1.CommandText = "[NewUpdateCommand]"
Me.SqlUpdateCommand1.CommandType = System.Data.CommandType.StoredProcedure
Me.SqlUpdateCommand1.Connection = Me.SqlConnection1
Me.SqlUpdateCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@RETURN_VALUE",
System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue,
False, CType(0, Byte), CType(0, Byte), "",
System.Data.DataRowVersion.Current, Nothing))
Me.SqlUpdateCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@firstname",
System.Data.SqlDbType.VarChar, 24, "firstname"))
Me.SqlUpdateCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@cboID", System.Data.SqlDbType.Int, 4))
'
'DsTest1
'
Me.DsTest1.DataSetName = "dsTest"
Me.DsTest1.Locale = New System.Globalization.CultureInfo("en-US")
'
'frmFirstName
'
Me.frmFirstName.DataBindings.Add(New System.Windows.Forms.Binding("Text",
Me.DsTest1, "NewSelectCommand.firstname"))
Me.frmFirstName.Location = New System.Drawing.Point(160, 84)
Me.frmFirstName.Name = "frmFirstName"
Me.frmFirstName.Size = New System.Drawing.Size(120, 20)
Me.frmFirstName.TabIndex = 0
Me.frmFirstName.Text = ""
'
'btnUpdate
'
Me.btnUpdate.Location = New System.Drawing.Point(176, 132)
Me.btnUpdate.Name = "btnUpdate"
Me.btnUpdate.Size = New System.Drawing.Size(96, 23)
Me.btnUpdate.TabIndex = 1
Me.btnUpdate.Text = "update"
'
'frmTest
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 14)
Me.ClientSize = New System.Drawing.Size(644, 457)
Me.Controls.Add(Me.btnUpdate)
Me.Controls.Add(Me.frmFirstName)
Me.Name = "frmTest"
Me.Text = "frmTest"
CType(Me.DsTest1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub frmTest_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.SqlDataAdapter1.SelectCommand.Parameters("@cboID").Value = 8
Me.SqlDataAdapter1.Fill(DsTest1)
End Sub
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnUpdate.Click
SqlUpdateCommand1.Parameters("@cboID").Value = 8
Me.SqlDataAdapter1.Update(DsTest1)
End Sub
End Class
I have a simple form with one text field binded to dataset.
for some reason when I call DA.UPDATE(DS) it's not working. I am using
stored procedures that are tested and working.
Thank you in advance
Here's the code:
Public Class frmTest
Inherits DevExpress.XtraEditors.XtraForm
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents SqlDataAdapter1 As System.Data.SqlClient.SqlDataAdapter
Friend WithEvents SqlConnection1 As System.Data.SqlClient.SqlConnection
Friend WithEvents SqlSelectCommand1 As System.Data.SqlClient.SqlCommand
Friend WithEvents SqlInsertCommand1 As System.Data.SqlClient.SqlCommand
Friend WithEvents SqlUpdateCommand1 As System.Data.SqlClient.SqlCommand
Friend WithEvents SqlDeleteCommand1 As System.Data.SqlClient.SqlCommand
Friend WithEvents DsTest1 As eXceLLe_TS.dsTest
Friend WithEvents frmFirstName As System.Windows.Forms.TextBox
Friend WithEvents btnUpdate As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.SqlDataAdapter1 = New System.Data.SqlClient.SqlDataAdapter
Me.SqlDeleteCommand1 = New System.Data.SqlClient.SqlCommand
Me.SqlConnection1 = New System.Data.SqlClient.SqlConnection
Me.SqlInsertCommand1 = New System.Data.SqlClient.SqlCommand
Me.SqlSelectCommand1 = New System.Data.SqlClient.SqlCommand
Me.SqlUpdateCommand1 = New System.Data.SqlClient.SqlCommand
Me.DsTest1 = New eXceLLe_TS.dsTest
Me.frmFirstName = New System.Windows.Forms.TextBox
Me.btnUpdate = New System.Windows.Forms.Button
CType(Me.DsTest1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'SqlDataAdapter1
'
Me.SqlDataAdapter1.DeleteCommand = Me.SqlDeleteCommand1
Me.SqlDataAdapter1.InsertCommand = Me.SqlInsertCommand1
Me.SqlDataAdapter1.SelectCommand = Me.SqlSelectCommand1
Me.SqlDataAdapter1.TableMappings.AddRange(New
System.Data.Common.DataTableMapping() {New
System.Data.Common.DataTableMapping("Table", "NewSelectCommand", New
System.Data.Common.DataColumnMapping() {New
System.Data.Common.DataColumnMapping("id", "id"), New
System.Data.Common.DataColumnMapping("firstname", "firstname")})})
Me.SqlDataAdapter1.UpdateCommand = Me.SqlUpdateCommand1
'
'SqlDeleteCommand1
'
Me.SqlDeleteCommand1.CommandText = "[NewDeleteCommand]"
Me.SqlDeleteCommand1.CommandType = System.Data.CommandType.StoredProcedure
Me.SqlDeleteCommand1.Connection = Me.SqlConnection1
Me.SqlDeleteCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@RETURN_VALUE",
System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue,
False, CType(0, Byte), CType(0, Byte), "",
System.Data.DataRowVersion.Current, Nothing))
Me.SqlDeleteCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@cboID", System.Data.SqlDbType.Int, 4,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"", System.Data.DataRowVersion.Original, Nothing))
'
'SqlConnection1
'
Me.SqlConnection1.ConnectionString = "workstation id=VLADO;packet
size=4096;user id=sa;data source=DEVSERVER;persist se" & _
"curity info=True;initial catalog=xllts;password=nothere"
'
'SqlInsertCommand1
'
Me.SqlInsertCommand1.CommandText = "[NewInsertCommand]"
Me.SqlInsertCommand1.CommandType = System.Data.CommandType.StoredProcedure
Me.SqlInsertCommand1.Connection = Me.SqlConnection1
Me.SqlInsertCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@RETURN_VALUE",
System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue,
False, CType(0, Byte), CType(0, Byte), "",
System.Data.DataRowVersion.Current, Nothing))
Me.SqlInsertCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@firstname",
System.Data.SqlDbType.VarChar, 24, "firstname"))
'
'SqlSelectCommand1
'
Me.SqlSelectCommand1.CommandText = "[NewSelectCommand]"
Me.SqlSelectCommand1.CommandType = System.Data.CommandType.StoredProcedure
Me.SqlSelectCommand1.Connection = Me.SqlConnection1
Me.SqlSelectCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@RETURN_VALUE",
System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue,
False, CType(0, Byte), CType(0, Byte), "",
System.Data.DataRowVersion.Current, Nothing))
Me.SqlSelectCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@cboID", System.Data.SqlDbType.Int, 4))
'
'SqlUpdateCommand1
'
Me.SqlUpdateCommand1.CommandText = "[NewUpdateCommand]"
Me.SqlUpdateCommand1.CommandType = System.Data.CommandType.StoredProcedure
Me.SqlUpdateCommand1.Connection = Me.SqlConnection1
Me.SqlUpdateCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@RETURN_VALUE",
System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue,
False, CType(0, Byte), CType(0, Byte), "",
System.Data.DataRowVersion.Current, Nothing))
Me.SqlUpdateCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@firstname",
System.Data.SqlDbType.VarChar, 24, "firstname"))
Me.SqlUpdateCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@cboID", System.Data.SqlDbType.Int, 4))
'
'DsTest1
'
Me.DsTest1.DataSetName = "dsTest"
Me.DsTest1.Locale = New System.Globalization.CultureInfo("en-US")
'
'frmFirstName
'
Me.frmFirstName.DataBindings.Add(New System.Windows.Forms.Binding("Text",
Me.DsTest1, "NewSelectCommand.firstname"))
Me.frmFirstName.Location = New System.Drawing.Point(160, 84)
Me.frmFirstName.Name = "frmFirstName"
Me.frmFirstName.Size = New System.Drawing.Size(120, 20)
Me.frmFirstName.TabIndex = 0
Me.frmFirstName.Text = ""
'
'btnUpdate
'
Me.btnUpdate.Location = New System.Drawing.Point(176, 132)
Me.btnUpdate.Name = "btnUpdate"
Me.btnUpdate.Size = New System.Drawing.Size(96, 23)
Me.btnUpdate.TabIndex = 1
Me.btnUpdate.Text = "update"
'
'frmTest
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 14)
Me.ClientSize = New System.Drawing.Size(644, 457)
Me.Controls.Add(Me.btnUpdate)
Me.Controls.Add(Me.frmFirstName)
Me.Name = "frmTest"
Me.Text = "frmTest"
CType(Me.DsTest1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub frmTest_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.SqlDataAdapter1.SelectCommand.Parameters("@cboID").Value = 8
Me.SqlDataAdapter1.Fill(DsTest1)
End Sub
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnUpdate.Click
SqlUpdateCommand1.Parameters("@cboID").Value = 8
Me.SqlDataAdapter1.Update(DsTest1)
End Sub
End Class