i need help in my project
i am work in activexpert software..i have vbs whish act with database from two column like this
aaa 15
gbn 55
rtg 41
when query about aaa the responce will be 15
what i want....i want to change the database , so the first column will be similar and i want to add one more column to the table. The value of this column can be either true or false.so will be like this
aaa 15 1
aaa 25 1
aaa 35 1
so when query about aaa the responce will be 15 and third column change to 0 ...so other query for aaa will not be 15 it jumb to next (25)
* the database name is stock.mdb
pleas help me in vbs to can do my project
this is the script
' // ========================================================================
Option Explicit
CONST STR_DEBUGFILE = "C:\Program Files\ActiveXperts\SMS Messaging Server\Sys\Tmp\mohamed01.txt"
CONST STR_DATABASEFILE = "C:\Program Files\ActiveXperts\SMS Messaging Server\Projects\mohamed01\Database\Stock.mdb"
' Declaration of global objects
Dim g_objMessageDB, g_objDebugger, g_objConstants
' Creation of global objects
Set g_objConstants = CreateObject( "AxMmServer.Constants" )
Set g_objMessageDB = CreateObject( "AxMmServer.MessageDB" )
Set g_objDebugger = CreateObject( "ActiveXperts.VbDebugger" )
' Set Debug file - for troubleshooting purposes
g_objDebugger.DebugFile = STR_DEBUGFILE
g_objDebugger.Enabled = False
' // ========================================================================
' // Function: ProcessMessage
' // ------------------------------------------------------------------------
' // ProcessMessage trigger function to process incoming messages
' // ========================================================================
Function ProcessMessage( numMessageID )
Dim objMessageIn, objMessageOut
g_objDebugger.WriteLine ">> ProcessMessage"
' Open the Message Database
g_objMessageDB.Open
If( g_objMessageDB.LastError <> 0 ) Then
g_objDebugger.WriteLine "<< ProcessMessage, unable to open database"
Exit Function
End If
' Retrieve the message that has just been received. If it fails then exit script
Set objMessageIn = g_objMessageDB.FindFirstMessage ( "ID = " & numMessageID )
If g_objMessageDB.LastError <> 0 Then
g_objMessageDB.Close
g_objDebugger.WriteLine "<< ProcessMessage, FindFirstMessage failed, error: [" & g_objMessageDB.LastError & "]"
Exit Function
End If
' Change Status to from Pending to Success. If you don't do it, the message will be processed by subsequent triggers (if defined) because message is still pending
objMessageIn.StatusID = g_objConstants.MESSAGESTATUS_SUCCESS
g_objMessageDB.Save objMessageIn
g_objDebugger.WriteLine "Incoming message saved, result: [" & g_objMessageDB.LastError & "]"
ProcessQuery ( objMessageIn )
' Close the Message Database
g_objMessageDB.Close
g_objDebugger.WriteLine "<< ProcessMessage"
End Function
' // ========================================================================
' // ProcessQuery
' // ------------------------------------------------------------------------
' // Parse the SMS and send a response back
' // ========================================================================
Function ProcessQuery ( objMessageIn )
Dim objMessageOut, curCurrentPrice, strReplymessage
g_objDebugger.WriteLine ">> ProcessQuery"
g_objDebugger.WriteLine "Selected Stock: " & objMessageIn.Body
If( QueryStock ( objMessageIn.Body, curCurrentPrice ) = False ) Then
strReplymessage = "Stock symbol not found. Please send a valid stock to query the current price, for instance: AXP"
Else
strReplymessage = "Current Price for " & objMessageIn.Body & ": $" & curCurrentPrice
End If
' Create the reply message
Set objMessageOut = g_objMessageDB.Create
If( g_objMessageDB.LastError = 0 ) Then
objMessageOut.DirectionID = g_objConstants.MESSAGEDIRECTION_OUT
objMessageOut.TypeID = g_objConstants.MESSAGETYPE_SMS
objMessageOut.StatusID = g_objConstants.MESSAGESTATUS_PENDING
objMessageOut.ToAddress = objMessageIn.FromAddress
objMessageOut.ChannelID = objMessageIn.ChannelID
objMessageOut.BodyFormatID = objMessageIn.BodyFormatID
objMessageOut.Body = strReplymessage
g_objMessageDB.Save objMessageOut
End If
g_objDebugger.WriteLine "<< ProcessQuery"
End Function
' // ========================================================================
' // Query stock
' // ------------------------------------------------------------------------
' // Lookup the current price of the selected stock ( use ticker symbol )
' // ========================================================================
Function QueryStock( strSymbol, BYREF curCurrentPrice )
Dim objConn, RS
Dim strQuery
QueryStock = False
g_objDebugger.WriteLine ">> QueryStock"
Set objConn = CreateObject("ADODB.Connection")
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & STR_DATABASEFILE & ";"
strQuery = "SELECT * FROM Stocks WHERE ID = '" & strSymbol &"'"
Set RS = objConn.Execute ( strQuery )
If( RS.EOF = False ) Then
curCurrentPrice = RS( "Value" )
QueryStock = True
Else
QueryStock = False
End If
' Close database
objConn.Close
Set objConn = Nothing
g_objDebugger.WriteLine "<< QueryStock"
End Function
i am work in activexpert software..i have vbs whish act with database from two column like this
aaa 15
gbn 55
rtg 41
when query about aaa the responce will be 15
what i want....i want to change the database , so the first column will be similar and i want to add one more column to the table. The value of this column can be either true or false.so will be like this
aaa 15 1
aaa 25 1
aaa 35 1
so when query about aaa the responce will be 15 and third column change to 0 ...so other query for aaa will not be 15 it jumb to next (25)
* the database name is stock.mdb
pleas help me in vbs to can do my project
this is the script
' // ========================================================================
Option Explicit
CONST STR_DEBUGFILE = "C:\Program Files\ActiveXperts\SMS Messaging Server\Sys\Tmp\mohamed01.txt"
CONST STR_DATABASEFILE = "C:\Program Files\ActiveXperts\SMS Messaging Server\Projects\mohamed01\Database\Stock.mdb"
' Declaration of global objects
Dim g_objMessageDB, g_objDebugger, g_objConstants
' Creation of global objects
Set g_objConstants = CreateObject( "AxMmServer.Constants" )
Set g_objMessageDB = CreateObject( "AxMmServer.MessageDB" )
Set g_objDebugger = CreateObject( "ActiveXperts.VbDebugger" )
' Set Debug file - for troubleshooting purposes
g_objDebugger.DebugFile = STR_DEBUGFILE
g_objDebugger.Enabled = False
' // ========================================================================
' // Function: ProcessMessage
' // ------------------------------------------------------------------------
' // ProcessMessage trigger function to process incoming messages
' // ========================================================================
Function ProcessMessage( numMessageID )
Dim objMessageIn, objMessageOut
g_objDebugger.WriteLine ">> ProcessMessage"
' Open the Message Database
g_objMessageDB.Open
If( g_objMessageDB.LastError <> 0 ) Then
g_objDebugger.WriteLine "<< ProcessMessage, unable to open database"
Exit Function
End If
' Retrieve the message that has just been received. If it fails then exit script
Set objMessageIn = g_objMessageDB.FindFirstMessage ( "ID = " & numMessageID )
If g_objMessageDB.LastError <> 0 Then
g_objMessageDB.Close
g_objDebugger.WriteLine "<< ProcessMessage, FindFirstMessage failed, error: [" & g_objMessageDB.LastError & "]"
Exit Function
End If
' Change Status to from Pending to Success. If you don't do it, the message will be processed by subsequent triggers (if defined) because message is still pending
objMessageIn.StatusID = g_objConstants.MESSAGESTATUS_SUCCESS
g_objMessageDB.Save objMessageIn
g_objDebugger.WriteLine "Incoming message saved, result: [" & g_objMessageDB.LastError & "]"
ProcessQuery ( objMessageIn )
' Close the Message Database
g_objMessageDB.Close
g_objDebugger.WriteLine "<< ProcessMessage"
End Function
' // ========================================================================
' // ProcessQuery
' // ------------------------------------------------------------------------
' // Parse the SMS and send a response back
' // ========================================================================
Function ProcessQuery ( objMessageIn )
Dim objMessageOut, curCurrentPrice, strReplymessage
g_objDebugger.WriteLine ">> ProcessQuery"
g_objDebugger.WriteLine "Selected Stock: " & objMessageIn.Body
If( QueryStock ( objMessageIn.Body, curCurrentPrice ) = False ) Then
strReplymessage = "Stock symbol not found. Please send a valid stock to query the current price, for instance: AXP"
Else
strReplymessage = "Current Price for " & objMessageIn.Body & ": $" & curCurrentPrice
End If
' Create the reply message
Set objMessageOut = g_objMessageDB.Create
If( g_objMessageDB.LastError = 0 ) Then
objMessageOut.DirectionID = g_objConstants.MESSAGEDIRECTION_OUT
objMessageOut.TypeID = g_objConstants.MESSAGETYPE_SMS
objMessageOut.StatusID = g_objConstants.MESSAGESTATUS_PENDING
objMessageOut.ToAddress = objMessageIn.FromAddress
objMessageOut.ChannelID = objMessageIn.ChannelID
objMessageOut.BodyFormatID = objMessageIn.BodyFormatID
objMessageOut.Body = strReplymessage
g_objMessageDB.Save objMessageOut
End If
g_objDebugger.WriteLine "<< ProcessQuery"
End Function
' // ========================================================================
' // Query stock
' // ------------------------------------------------------------------------
' // Lookup the current price of the selected stock ( use ticker symbol )
' // ========================================================================
Function QueryStock( strSymbol, BYREF curCurrentPrice )
Dim objConn, RS
Dim strQuery
QueryStock = False
g_objDebugger.WriteLine ">> QueryStock"
Set objConn = CreateObject("ADODB.Connection")
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & STR_DATABASEFILE & ";"
strQuery = "SELECT * FROM Stocks WHERE ID = '" & strSymbol &"'"
Set RS = objConn.Execute ( strQuery )
If( RS.EOF = False ) Then
curCurrentPrice = RS( "Value" )
QueryStock = True
Else
QueryStock = False
End If
' Close database
objConn.Close
Set objConn = Nothing
g_objDebugger.WriteLine "<< QueryStock"
End Function