Quantcast
Channel: VBForums - ASP, VB Script
Viewing all articles
Browse latest Browse all 688

Have a form that can process an update or insert - how to evaluate.

$
0
0
I have a report that generates a list of servers, local User accts and a Custom Label. I have a form that will allow a user to manually put in the information but there is also a service that could add the Server Name and Local user acct.

So I need my form to first see if the server name and local user acct exist, if it does, then update the column Custom Label. Else I need too insert the Server Name, Local user acct and Custom Label.

Code:

<%@ Language=VBScript %>
<% Option Explicit %>
<!-- #include file = "conn.asp" -->
<!--#include virtual="adovbs.inc"-->
<%  DIM strServer,cpSearch,strUserlbl,strUserID,User_ID
strServer = Request.Form("servername")
strUserID = Request.Form("userid")
strUserlbl = Request.Form("useracctlbl")
%>
<%
  Dim objRS,objConn,testSQL,objRS2, mySQL
  Set objConn = Server.CreateObject("ADODB.Connection")
  objConn.ConnectionString = sConnection
  objConn.Open
  testSQL = "select count(*) AS Userlbl from LocalUserLabel where server_name =  '" & strServer & "'" and User_ID =  "'" & strUserID & "'"
if Userlbl = 0 then
  Set objRS = Server.CreateObject("ADODB.Recordset")
  objRS.Open "LocalUserLabel", objConn, adOpenStatic, adLockOptimistic, adCmdTable
  objRS.AddNew Array("Server_Name", "User_ID", "CustomLabel"), Array(uCase(Request.Form ("servername")), Request.Form("userid"), uCase(Request.Form("useracctlbl")))
  objRS.Update
 end if
if Userlbl = 1 then
mySQL = "SELECT * FROM server WHERE server_name = '" & strServer & "'"
      Set objRS2 = Server.CreateObject("ADODB.Recordset")
      objRS2.Open mySQL, objConn, adOpenKeyset, adLockPessimistic, adCmdText
objRS2("CustomLabel") = Request.Form("useracctlbl")
  objRS2.Update
  end if
  objRS.Close
  Set objRS = Nothing
  objRS2.Close
  Set objRS2 = Nothing
  objConn.Close
  Set objConn = Nothing
  Response.Redirect "customerLabelrpt.asp"
%>

I get an error:

Type mismatch: '[string: "select count(*) AS U"]'

Can I please get some assistance on creating my page. Let me know if any other information is needed.

Thanks,

Viewing all articles
Browse latest Browse all 688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>