I have tried a few different way to write this script. I need to prompt for Item Number and then display what shows up in the Avg_Cost along with the Item Number and Price
Just been testing with trying to get the Item Number and Average Cost to display but it has been a failure.
Here is one of the many versions of writing this:
dim dbconnection, sqlrs, itemno, sql
Const CONNECT_STRING = "provider=SQLOLEDB.1;Presist Security info=True;User ID=sa;Initial Catalog=AAAAAA;Data Source=BBBBBB;password=CCCCCC"
Set WshShell = WScript.CreateObject("WScript.Shell")
set objFSO = CreateObject("Scripting.FileSystemObject")
Set dbconnection = createobject("ADODB.connection")
Set sqlrs = createobject("ADODB.Recordset")
Itemno = InputBox("Enter Item Number:", "Item Number")
SQL = "SELECT avg_cost FROM [AAAAAA].[dbo].[IM_INV] where ITEM_NO = ITEMNO and LOC_ID = 'MAIN'"
dbconnection.open CONNECT_STRING
dbconnection.execute SQL
Set SQLRS = dbconnection.OpenRecordset(SQL)
wscript.echo "Average Cost of item "& ITEMNO & " is " & sqlrs("avg_cost")
SQLRS.Close
dbconnection.close
I am so not a programmer or database guy so any guidance would be greatly appreciated.
Just been testing with trying to get the Item Number and Average Cost to display but it has been a failure.
Here is one of the many versions of writing this:
dim dbconnection, sqlrs, itemno, sql
Const CONNECT_STRING = "provider=SQLOLEDB.1;Presist Security info=True;User ID=sa;Initial Catalog=AAAAAA;Data Source=BBBBBB;password=CCCCCC"
Set WshShell = WScript.CreateObject("WScript.Shell")
set objFSO = CreateObject("Scripting.FileSystemObject")
Set dbconnection = createobject("ADODB.connection")
Set sqlrs = createobject("ADODB.Recordset")
Itemno = InputBox("Enter Item Number:", "Item Number")
SQL = "SELECT avg_cost FROM [AAAAAA].[dbo].[IM_INV] where ITEM_NO = ITEMNO and LOC_ID = 'MAIN'"
dbconnection.open CONNECT_STRING
dbconnection.execute SQL
Set SQLRS = dbconnection.OpenRecordset(SQL)
wscript.echo "Average Cost of item "& ITEMNO & " is " & sqlrs("avg_cost")
SQLRS.Close
dbconnection.close
I am so not a programmer or database guy so any guidance would be greatly appreciated.