ExecuteNonQuery Update Not Working

J

johnnymack0730

Hello -

I am currently working on an asp.net application that needs to be able
to update an access table using ExecuteNonQuery method. I have all the
code setup, it runs, there are no errors thrown, yet...nothing is being
updated. The only thing I can see is the ExecuteNonQuery returns 0
when the update is run. Can anyone help please?

Here is some of the code:

Dim strUpdateServers As String
Dim strUpdateServerDataCenter As String
Dim sqlConn As New OleDbConnection
Dim strConnection As String
Dim strdebug As String

strUpdateServers = "Update [Servers] Set [ServerType] =
@ServerType, " & _
"[Tier] = @ServerFunction, [Platform] = @Platform, " & _
"[NumAffectedUsers] = @NumUsersAffected, [NumPrintQueues] =
@NumPrintQueues, " & _
"[NumUsersWithAccounts] = @NumUsersWithAccounts,
[NumDesktops] = @NumDeskTops, " & _
"[OsVer] = @OsVer, [ServicePack] = @ServicePack, " & _
"[HotFixes] = @HotFixes, [StorageConfig] = @StorageConfig, "
& _
"[SerialNumber] = @SerialNumber, [FormFactor] = @FormFactor,
" & _
"[RackTower] = @RackTower, [Make] = @Make, " & _
"[Model] = @Model, [ProcessorType] = @ProcessorType, " & _
"[ProcessorQty] = @ProcessorQty, [ProcessorSpeed] =
@ProcessorSpeed, " & _
"[PhysMemSize] = @PhysMemSize, [PhysMemType] = @PhysMemType,
" & _
"[NetEISS] = @NetEISS, [TagNumber] = @TagNumber, " & _
"[NetBIOSSysName] = @NetBIOSSysName, [SNMPPubCommunity] =
@PubCommunity, " & _
"[SNMPPrivCommunity] = @PrivCommunity WHERE [ServerName] =
@ServerName"

'Get connection string from Web.Config
strConnection =
ConfigurationSettings.AppSettings("ConnectionString")
sqlConn = New OleDbConnection(strConnection)
sqlConn.Open()

Dim myCommand As OleDbCommand = New
OleDbCommand(strUpdateServers, sqlConn)
myCommand.CommandType = CommandType.Text

Dim parmServerType As OleDbParameter = _
New OleDbParameter("@ServerType", OleDbType.VarWChar)
parmServerType.Value =
(lstServerType.SelectedItem.Value.ToString)

myCommand.Parameters.Add(parmServerType)

Dim parmServerFunction As OleDbParameter = _
New OleDbParameter("@ServerFunction", OleDbType.VarWChar)
parmServerFunction.Value =
(lstServerFunction.SelectedValue.ToString)
myCommand.Parameters.Add(parmServerFunction)

Dim parmPlatform As OleDbParameter = _
New OleDbParameter("@Platform", OleDbType.VarWChar)
parmPlatform.Value = (lstPlatform.SelectedValue.ToString)
myCommand.Parameters.Add(parmPlatform)


.... rest of the parameters setup code ...


Try
Dim i as integer
i = myCommand.ExecuteNonQuery() 'Execute the UPDATE servers query
Response.Write i.ToString ' used to see result of update.
Catch ex As Exception
Response.Write("Error updating Servers Table")
Response.Write(ex.Message)
End Try
 

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

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top