Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old April 13th, 2007, 05:15 PM
David
Guest
 
Posts: n/a
Default Run SQL on form button and output result on page

Hi,

I have an asp page with a form.
A user enters a serial number in a text box.

I want to add a button next to the text box such as 'Check Serial' to
run some SQL in the background to see if that serial exists in the
table, and then output 'Serial found' or 'Serial Not Found' next to
the text box, so the user can decide whether to continue with the
form.


Appreciate your help.



Thanks


David

  #2  
Old April 14th, 2007, 10:55 AM
Mike Brind
Guest
 
Posts: n/a
Default Re: Run SQL on form button and output result on page


"David" <davidgordon@scene-double.co.ukwrote in message
news:1176480364.542772.296270@y5g2000hsa.googlegro ups.com...
Quote:
Hi,
>
I have an asp page with a form.
A user enters a serial number in a text box.
>
I want to add a button next to the text box such as 'Check Serial' to
run some SQL in the background to see if that serial exists in the
table, and then output 'Serial found' or 'Serial Not Found' next to
the text box, so the user can decide whether to continue with the
form.
>
Have a look at the xmlhttpobject in javascript: www.w3schools.com/ajax

--
Mike Brind


  #3  
Old April 20th, 2007, 08:45 PM
xxshoexx@gmail.com
Guest
 
Posts: n/a
Default Re: Run SQL on form button and output result on page

Using VB and ADO I have stored proc that checks for a value and give
the return value. And kicks off the event onBlur

<SCRIPT LANGUAGE="vbscript">
Public Sub getID(id)
Dim cn: Set cn = CreateObject("ADODB.Connection")
Dim cmd: Set cmd = CreateObject("ADODB.Command")
Dim rs: Set rs = CreateObject("ADODB.Recordset")

'cn.Open "db.udl"
cn.Open "Provider=SQLOLEDB.1;Password=[Password];Persist
Security Info=True;User ID=[UserID];Initial Catalog=[Database];Data
Source=[Server Name]"
cn.CursorLocation = 3
cmd.ActiveConnection = cn
cmd.CommandType = 4

cmd.CommandText = "[dbo].[View:GetID]"
cmd.Parameters.Append (cmd.CreateParameter ("@ID",3, 1, 0,
Null ))
cmd.Parameters.Item("@ID").Value = id
rs.Open cmd

If rs.RecordCount = 0 Then
MsgBox id & " is not a valid ID.", vbOkOnly, "Error"
document.all("WorkoutID").Value = ""
document.all("WorkoutName").innerHTML = ""
Else
document.all("WorkoutID").Value = id
document.all("WorkoutName").innerHTML =
rs.Fields.Item("Topic")

End if
End Sub
</SCRIPT>


<input name="WorkoutID" size="5" type="text"
onblur="vbscript:getId(WorkoutID.value)">


  #4  
Old April 20th, 2007, 08:55 PM
Bob Barrows [MVP]
Guest
 
Posts: n/a
Default Re: Run SQL on form button and output result on page

xxshoexx@gmail.com wrote:
Quote:
Using VB and ADO I have stored proc that checks for a value and give
the return value. And kicks off the event onBlur
>
<SCRIPT LANGUAGE="vbscript">
Public Sub getID(id)
Dim cn: Set cn = CreateObject("ADODB.Connection")
Dim cmd: Set cmd = CreateObject("ADODB.Command")
Dim rs: Set rs = CreateObject("ADODB.Recordset")
>
'cn.Open "db.udl"
cn.Open "Provider=SQLOLEDB.1;Password=[Password];Persist
Security Info=True;User ID=[UserID];Initial Catalog=[Database];Data
Source=[Server Name]"
Dangerous! You do realize this is all visible to the user simply via
View|Source ??

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


  #5  
Old May 4th, 2007, 11:55 AM
xxshoexx@gmail.com
Guest
 
Posts: n/a
Default Re: Run SQL on form button and output result on page

On Apr 20, 3:48 pm, "Bob Barrows [MVP]" <reb01...@NOyahoo.SPAMcom>
wrote:
Quote:
xxsho...@gmail.com wrote:
Quote:
Using VB and ADO I have stored proc that checks for a value and give
the return value. And kicks off the event onBlur
>
Quote:
<SCRIPT LANGUAGE="vbscript">
Public Sub getID(id)
Dim cn: Set cn = CreateObject("ADODB.Connection")
Dim cmd: Set cmd = CreateObject("ADODB.Command")
Dim rs: Set rs = CreateObject("ADODB.Recordset")
>
Quote:
'cn.Open "db.udl"
cn.Open "Provider=SQLOLEDB.1;Password=[Password];Persist
Security Info=True;User ID=[UserID];Initial Catalog=[Database];Data
Source=[Server Name]"
>
Dangerous! You do realize this is all visible to the user simply via
View|Source ??
>
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
not if you put it inside of server side tags

  #6  
Old May 4th, 2007, 11:55 AM
xxshoexx@gmail.com
Guest
 
Posts: n/a
Default Re: Run SQL on form button and output result on page

On Apr 20, 3:48 pm, "Bob Barrows [MVP]" <reb01...@NOyahoo.SPAMcom>
wrote:
Quote:
xxsho...@gmail.com wrote:
Quote:
Using VB and ADO I have stored proc that checks for a value and give
the return value. And kicks off the event onBlur
>
Quote:
<SCRIPT LANGUAGE="vbscript">
Public Sub getID(id)
Dim cn: Set cn = CreateObject("ADODB.Connection")
Dim cmd: Set cmd = CreateObject("ADODB.Command")
Dim rs: Set rs = CreateObject("ADODB.Recordset")
>
Quote:
'cn.Open "db.udl"
cn.Open "Provider=SQLOLEDB.1;Password=[Password];Persist
Security Info=True;User ID=[UserID];Initial Catalog=[Database];Data
Source=[Server Name]"
>
Dangerous! You do realize this is all visible to the user simply via
View|Source ??
>
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup

Also can just do async calls with it.

  #7  
Old May 4th, 2007, 01:05 PM
Bob Barrows [MVP]
Guest
 
Posts: n/a
Default Re: Run SQL on form button and output result on page

xxshoexx@gmail.com wrote:
Quote:
On Apr 20, 3:48 pm, "Bob Barrows [MVP]" <reb01...@NOyahoo.SPAMcom>
wrote:
Quote:
>xxsho...@gmail.com wrote:
Quote:
>>Using VB and ADO I have stored proc that checks for a value and give
>>the return value. And kicks off the event onBlur
>>
Quote:
>><SCRIPT LANGUAGE="vbscript">
<snip>
Quote:
Quote:
>Dangerous! You do realize this is all visible to the user simply via
>View|Source ??
<snip>
Quote:
not if you put it inside of server side tags
But your example shows it in a client-side script element.
At least now you are aware of the desirability to do this in server-side
code,
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


  #8  
Old May 4th, 2007, 01:05 PM
Bob Barrows [MVP]
Guest
 
Posts: n/a
Default Re: Run SQL on form button and output result on page

xxshoexx@gmail.com wrote:
Quote:
>
Also can just do async calls with it.
And why is this relevant? If it is in client-side script, the user can see
it, whether async calls are done with it or not.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles