How to insert records into COMMON_SETTINGS table using Common Settings Object?
Question ID: 109382
0
0

Hi,

How to insert data shown in attached screenshot into COMMON SETTINGS table?

Below is the code which I have tried:

<Code>

Sub FetchRecordSetQuery()

BeginRow_Data = 2
LastRow = ThisWorkbook.Sheets(“Input”).UsedRange.Rows.Count
LastCol = ThisWorkbook.Sheets(“Input”).UsedRange.Columns.Count
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
Set objLog = objFSO.CreateTextFile(“c:\temp\log1.log”)
For i = 2 To 4 ‘LastRow
ThisWorkbook.Save
DoEvents
If Trim(Sheets(“Input”).Range(“I” & i)) <> “” Then

Dim C_CATEGORY, C_NAME, C_OWNER, C_VALUE, C_IS_SYSTEM, C_ID, PROJECT_NAME, DOMAIN_NAME As String
Dim Esign As Variant
‘Dim cs As CommonSettings

C_CATEGORY = Trim(Sheets(“Input”).Range(“A” & i))
C_NAME = Trim(Sheets(“Input”).Range(“B” & i))
C_OWNER = Trim(Sheets(“Input”).Range(“C” & i))
C_VALUE = Trim(Sheets(“Input”).Range(“D” & i))
C_IS_SYSTEM = Trim(Sheets(“Input”).Range(“E” & i))
C_ID = Trim(Sheets(“Input”).Range(“F” & i))

PROJECT_NAME = Trim(Sheets(“Input”).Range(“I” & i))
DOMAIN_NAME = Trim(Sheets(“Input”).Range(“J” & i))
Esign = “N.A”

objLog.WriteLine ” ”
objLog.WriteLine i & ” ” & C_CATEGORY & ” ” & C_NAME & ” ” & C_OWNER & ” ” & C_VALUE & ” ” & C_IS_SYSTEM & ” ” & C_ID & ” ” & PROJECT_NAME & ” ” & DOMAIN_NAME & ” ” & Esign
MyMessage = i & ” ” & C_CATEGORY & ” ” & C_NAME & ” ” & C_OWNER & ” ” & C_VALUE & ” ” & C_IS_SYSTEM & ” ” & C_ID & ” ” & PROJECT_NAME & ” ” & DOMAIN_NAME & ” ” & Esign

Application.StatusBar = MyMessage

‘Set tdc = CreateObject(“tdapiole80.tdconnection”)
Set tdc = New TDAPIOLELib.TDConnection
tdc.InitConnectionEx (“https://ABCD.com/qcbin”)
tdc.Login “userid”, “password”
tdc.Connect DOMAIN_NAME, PROJECT_NAME
‘After Connecting to project add the record to COMMON_SETTINGS table
Set cs = tdc.CommonSettings
cs.Open CSET_CATEGORY

cs.Value(C_NAME) = C_NAME
cs.Value(C_OWNER) = C_OWNER
cs.Value(C_VALUE) = C_VALUE
‘ cs.Value(“C_IS_SYSTEM”) = C_IS_SYSTEM

cs.Close
cs.Post
Set cs = Nothing

tdc.Disconnect
tdc.ReleaseConnection
End If
Next

Application.StatusBar = False
ThisWorkbook.Save
MsgBox “Execution Completed”
End Sub

</code>

Will there be any impact if we insert the record directly into common settings table using SQL command object?

Thanks,Srihari

Attachments:
Marked as spam
Posted by (Questions: 33, Answers: 21)
Asked on March 5, 2020 1:29 pm
75 views
EyeOnTesting

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

X
Scroll to Top