Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBScript not executing

Status
Not open for further replies.

sharonc

Programmer
Jan 16, 2001
189
US
I have a form that the user enters the data and then clicks on email. At this point the data is emailed to another user. For some reason my data source is now showing as read-only, can someone tell me how to fix this? The other problem is this code is not executing at all, Can someone tell me what I need to do to get this code to execute?
Thank you for your help, it is greatly appreciated.

<%@ language=vbscript %>
<% Option Explicit %>

<%
Dim Conn, rs, sqlStatement, strHost, Msg

Set Conn = CreateObject(&quot;ADODB.Connection&quot;)
Conn.Open = &quot;Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Forms;Data Source=SEIMS&quot;
Conn.CursorLocation = adUseServer

sqlStatement = &quot;dbo_Contractors&quot;
Set rs = CreateObject(&quot;ADODB.Recordset&quot;)
rs.open sqlStatement, Conn,,adLockOptimistic, adCmdTable


strHost = &quot;mail.aepnet.com&quot;

Set Mail = CreateObject(&quot;Persits.MailSender&quot;)
Mail.Host = strHost

'format the new mail message
Mail.From = &quot;schapman@aepnet.org&quot;
Mail.AddAddress &quot;schapman@aepnet.org&quot;

' message subject
Mail.Subject = &quot;Contractors Working At Apache&quot;

' message attachment
'Mail.AddAttachment &quot;g:\Inetpub\
' message body
'Msg.Body = Msg & rs(&quot;ContractorFirstName&quot;)
Msg = &quot;Contractor Name: &quot; & rs(&quot;ContractorFirstName&quot;) Mail.Body = Msg

'SEND THE MAIL MESSAGE TO ITS RECIPIENTS
mail.Send

If Err <> 0 Then
Response.Write &quot;An error occurred: &quot; & Err.Description
End If

'DEFERENCE THE OBJECT AND DESTROY ITS INSTANCE
set Mail = Nothing

%>
 
your sql statement isn't complete. it looks like you're naming the table but not telling it the info you want out of it. you need something like:

sqlstatement=SELECT * FROM dbo_contractors WHERE variable = &quot;somevalue&quot;

depending on what you want to send.

hth
mark
 
OK I changed my code to this:

<%@ language=vbscript %>
<% Option Explicit %>

<%
Dim Conn, rs, sqlStatement, strHost, Msg

Set Conn = CreateObject(&quot;ADODB.Connection&quot;)
Conn.Open = &quot;Provider=SQEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Forms;Data Source=SEIMS&quot;
Conn.CursorLocation = adUseServer

sqlStatement = &quot;Select * from dbo_Contractors&quot;
Set rs = CreateObject(&quot;ADODB.Recordset&quot;)
rs.open sqlStatement, Conn,,adLockOptimistic, adCmdTable


strHost = &quot;mail.aepnet.com&quot;

Set Mail = CreateObject(&quot;Persits.MailSender&quot;)
Mail.Host = strHost

'format the new mail message
Mail.From = &quot;schapman@aepnet.org&quot;
Mail.AddAddress &quot;schapman@aepnet.org&quot;

' message subject
Mail.Subject = &quot;Contractors Working At Apache&quot;

' message attachment
'Mail.AddAttachment &quot;g:\Inetpub\
' message body
'Msg.Body = Msg & rs(&quot;ContractorFirstName&quot;)
Msg = &quot;Contractor Name: &quot; & rs(&quot;ContractorFirstName&quot;) Mail.Body = Msg

'SEND THE MAIL MESSAGE TO ITS RECIPIENTS
mail.Send

If Err <> 0 Then
Response.Write &quot;An error occurred: &quot; & Err.Description
End If

'DEFERENCE THE OBJECT AND DESTROY ITS INSTANCE
set Mail = Nothing

%>

It still doesn't execute. If I place a stop and try to debug, it never reaches the stop. It is also still showing as read-only data source. Do you have any other suggestions?

Thank you.
 
I know that &quot;stop&quot; works in VBA but I'm not sure it's supported in vbscript. You might consider using just a response.write at random points in the codes so you can see how far it does run. I'd prolly response.write the sql statement (make sure it's reading right). I'm still learning a lot of this so this might be a dumb question but, in your rs.open line, you've got [red]Conn,,[/red] Is that second comma needed? Sorry I can't be of more help but still fairly new at this myself.
hth
mark
 
I tried the response write and it didn't print anything out. The data is displaying in the form. Do you know if this should have a .asp or a .html for the extension? Thank you for your help, I'm afraid I'm new at this too.
 
I had a similar problem are you using front page? if so I went to publicise web in the file menu and selected the whci I was using and publicised it and then I could see results of the response.write because befor like you it did absolutely nothing. Its something small but you neve know???
Róisín
 
I did use FrontPage to creat my form and then I added VBScript code. Thank you, I'll give it a try.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top