Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    ASP




Inserting 2 Different ASP Statements Into One ASP File


I have two ASP statements (<% , %>) that I would like to insert into one ASP file. One of the statements is already inserted in the file and works successfully.
However, when I insert the second ASP statement, the page comes up with an error;-

"Microsoft VBScript compilation error '800a0411'

Name redefined "

I am pretty sure I get this error because both statements are conflicting with one another.
I also can't combine the two statements as I use a DSN connection for one, and a DSN-less connection for another and I connect to 2 different databases.

How might I be able to include both ASP statements within the single ASP file?

A user on another Forum said " there is a variable DIMmed twice.

easiest way is a third include with the variable names in. That way it can be used with any combination of the includes."




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Multiple Possible Include File Statements
For some reason, I am having trouble with this. I want to have a select statement, such as -

<%
Select Case Request("service")
Case "s"
<!-- #include file="includes/bottom_nav.inc" -->
Case "p"
<!-- #include file="includes/bottom_nav.inc" -->
Case "a"
<!-- #include file="includes/bottom_nav.inc" -->
End Select
%>

I know that is not the correct syntax for the include files.

Inserting Date In Csv File
I am trying to insert the date into a *.csv file using the following line

csvBody = csvBody & "" & fix(FormatDateTime(now(), vblongdate) & ""

The fix function is as follows

function fix(strInput)

strInput = replace(strInput, """", "")
strInput = replace(strInput, vbNewLine, " ")

fix = strInput
end function

I would like the Date to appear as Wednesday 16th June 2005 within a single cell (without commas).

Inserting Into Oracle Using A Csv File
I have to read from a csv file (; delimited) and insert it into an oracle table using asp. the file can be anywhere in the local. so is it possible to use a form and get the file name or the location as an argument. Also how do i do the insert in the existing table. Code:

Inserting Signature Bitmap File In An Asp
I am trying to build a asp page where signature bitmap file needs to be
inserted from a directory. The path of the file location is in one of the
backend Access database fields. I would like to know if there is any
knowledge based article related to this kind of issues. I have no idea where
to start on this.

How To Get Data From An Excel File And Inserting Them Into A Database Using Asp?
I would like to know if there are any tutorials out there or websites that can explain more about this? can this be done in asp?

Validating An Uploaded File Before Inserting Data In To Database
I am uploading a file using ASP code. After the user uploads the file, I would like to be able to open the file and check if the data is in a given format (comma separated) and also has all the data elements needed (i.e. all fields are there).

Is there a parse routine in asp that would allow me to do this. The user can upload any type of file as long as I am able to parse it and determine if the data is of the aforemention type.

Carriage Return Before Inserting Text Into Acess Database File. How To Do It?
how to replace carriage return upon extracting text from Access file.

However I think it will be smarter to do it before (during) inserting text into acess file.

It might be primitive question, but I started my ASP learning just last week and many things are confusing me on this stage.

QUESTION:

What should I change in my ASP file code (file inserted data from the HTML form file into database file) to replace all carriage returns and line brakes during inserting text into field GuestSory? Code:

Asp If Statements
I need some help with some if statements in an asp page I got. My sql statement is:

sql = "select * from courseDesc"

I want to logically diplay all the information on the page. So I inserted this if statement to choose the information I want to dispaly:

<% if rs("courseName") = "whatIsCist" then
response.write(rs("description"))
end if %>

Other courseName titles I need to display the information for further down the page, include: wdt, lan, wan, programming, admissionReq1,2,&3. Does anyone see where my problem is?

IF Statements
I'm having problems getting some ASP code to work with a form I'm using. I'm using the script with a multiple page form and want to print a javascript onsubmit value for just one of the forms. I'm getting errors because of the multiple IF statements and I'm not sure how to do this and have the "s show up properly in the output. Can someone tell me how to do this properly?

Code:
<% If step < 5 Then Response.Write " <form action="/script.asp" method="post" name="theForm" id="theForm" & If step < 1 Then Response.Write " onsubmit=""" & "return checkForm(this);" & End If %> & ">" & End If %>
Here is how I want it to output:

<form action="/script.asp" method="post" name="theForm" id="theForm" onsubmit="return checkForm(this);">

Use Or And Statements
is there a way to use "or, and" statements in asp,
what i want to do it do 2 seperate checks on the database and if one is true or the other one is true then display some text is this possible and also the same check again on the database but the first statement and the second statement has to be true then display some text is this possible, if yes how would i do it?

If Then Statements
I have a field on an asp form called hotelYesNo (YesNo value-pulldown) and a field called roomMate.

I want to do an If Then statement likeso: If hotelYesNo = Yes Then roomMate is required, but if hotelYesNo = No Then roomMate is not required.

I don't know how to get this accomplished in the asp code.

I know how to do this in Microsoft Access but not on a webpage.

How would this be done?

If Then Statements
I want to run a query and need to use If then statements such as: If this is output, then run this query. Is there a way to do this?

If Statements
I didn't really get a direct answer in the .net forum so I guess I'll just post it here where it should be anyway. Instead of .net I'm just going to probaly stick with 3.0. I want to have several different templates for users to browse a site in.

Since I can't use include files in ASP is there a way I can ONLY load coding in an if statement as it applys to that certain user? I want to enclose multiple images and coding into one file but only load the ONE image/code that pertains to the user. Is this possible using if statements?

IF Statements
i am trying to find out if three feilds in a record match, if so send it to another page. basically see code.

Quote: rs.Open "Rental", cs, adOpenDynamic
Do Until rs.EOF
If rs.Fields("MemberID").Value=person And rs.Fields("DVDID").Value=dvd And rs.Fields("Current").Value=true then
Response.redirect "copy.asp?memberid=" & person
End If
rs.MoveNext
Loop

this does not bring up a problem just does not do it any ideas on if staemenst etc in asp thingy.

ASP And SQL Statements
I have a (hopefully) simple question that has been giving me some problems. I'm trying to use a simple Select statement to access some data in an access database. In access, the sql statement is as follows:

SELECT TPL_Checklist_Master.[1] From TPL_Checklist_Master

However, when I try to do this on an ASP Page, it always causes an error. I'm assuming this is because of the [] around the field name 1. (I would change the field names, but I don't have control over that).

I know when trying to use a * in the statement Where field LIKE 'A*' I needed to replace the * with a %. I was wondering if something similar had to be done in this case.
I hope my description is clear enought to follow.

Asp If Statements
We have currently launched a website in ASP and now want to add some tracking functions.
We have banner ads and emails that we are launching.I would like to create code that will allow me to change the an image and a text link based on where the user is linking in from.

I.e If they clicked on banner xy - then the index page the images would be xy and the text box in another page would be xy. if they clicked on banner zz - then the index page the images would be zz and the text box in another page would be zz.

Include Statements
I have been avoiding this issue but it keeps popping up and I cannot figure out a solution. Include statements pathed two or more folders deep they break.

This works:
<!--#include file="../includes/mo_security.asp" -->

This does not work:
<!--#include file="../../includes/mo_security.asp" -->

So basically my site files are limited to one folder deep.
Ex: ROOT/parentFolder/files.htm
One I move another level down the includes do not work anymore:
Ex: ROOT/parentFolder/childFolder/files.htm
I am on a Windows IIS server. Is there any solution to this or is it just a limitation of the include statement?

Converting Sql Statements
I have a project to do that requires that I use mysql as the database. I have only used MS Access. The sql will be simple searches.
Is there a drastic difference, or just different punctuation?
Can I find a copy of mysql on the web? If so, is there any advice on installing?

VBScript If Statements
Is it possible to wirte a VBScript If statment that outputs different HTML? IE: If **** = True then do this HTML else do this HTML?
How do you do something like that?

LIKE Operator For IF Statements?
Basicly I pull the whole column contents and what to test to see if the username is that list. How can I do this in an if statement. I know how to do this kind of thing in SQL (LIKE operator) but I need to test agains two recordsets. Code:

ASP With SQL Insert Statements
Question 1: How can have th asp script automatically convert the date generated by the system to a format which is acceptable by Sybase SQL (yyyymmdd)

Question 2: If the user were to insert a a string containing " ' ", how can I convert it into a special character so that it won't be treated by Sybase SQL as the start/end of a variable?

<!--#include--> Statements
I am using the ASP include statements for some HTML code, and I have the <body></body> tags included in an outside <!--#include--> file. Is this OK? Or could it mess something up not having the <body></body> tags in the actual page HTML?

Sql Update Statements
I am getting an error on my sql update statement and I can't find where it is. I am getting the message, "syntax error in update statement". when I do a response.write on my sql statement this is what I get back

update tblUser set lastname='Ray', firstname='David', address='petal ms', email='david@ray.com', pass='dray', where username='dray'

Using If Then Statements In Href Tag
Is it possible to use If Then statements in an a href tag? What I am trying to do is I am using a server side include page of navigation inside of a content management system. I have limitations on what I can manipulate and change. So just using style sheets won't do me the trick. I want to have a navigation link change a different color when you are on that section. I have the menu expanding also using if then statements. When a variable is passed somewhere else on the page as true, the menu expands. I figured I could use this in the same way to make the link change colors. I want to do something like:

<A href="#" <% If Variable_name then%> id="link <% end if %>>Link Here </a>

Is that possible? I know that i can do an If then statement and have 2 different links, one with the id and one without, but I wanted to see if I could simplify it at all. I'm not the best with ASP so there might even be better ways then that...I was just using from the little that I knew.

Combine Two Statements
I'd like to combine if possible these two statements drawing from a total of 3 tables.

sql = "SELECT p.Sub_ID, p.Cat_ID, p.Sub_Name, COUNT(c.Sub_ID) as ct FROM
Subs p LEFT JOIN Links c ON p.Sub_Id = c.Sub_Id GROUP BY p.Sub_ID, p.Cat_ID,
p.Sub_Name ORDER BY p.Sub_Name"

sql = "select * from Subs inner join Cats on Cats.Cat_ID=Subs.Cat_ID ORDER
BY Sub_Name"

Is it possible? Am I totaly screwed up for even trying? The goal is to count the relations ships in the Subs and Links table based on Sub_ID, to display needed data from the Subs table, and to display the Cat_name table from the Cats table in relationship to the Cat_ID in both the Cats and Subs Table.

Prepared Statements
I am trying to create a prepared statement in ASP, but am having problems with creating the parameter object. I do the following

Set fnParam = peopleUpdate.CreateParameter("@firstname", adVarChar,
adParamInput, 50, peopleSourceRS("firstname"))

But this gives the following error on the browser:

Error Type:
ADODB.Command (0x800A0BB9)

Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another. The server doesn't seem to like adVarChar and adParamInput. I did try
to create the parameter without arguments and then assign the properties, but it gives the same error for .Type and .Direction. What am I doing incorrectly here?

Joining Two SQL Statements
I have these two statements and I want to join them to make one query, i don't know how to do it since there are two querystrings that are selecting my data for me.

sSQL = "SELECT * FROM AssemblyName Where AssemblyName = '" & Request.QueryString("assembly") & "'"
Set oRS = oConn.Execute(sSQL)

sSQL = "SELECT * FROM PartsList Where ID = '" & Request.QueryString("one") & "'"
Set oRS2 = oConn.Execute(sSQL)

If Statements And Wildcards
if not request("email") like "%@%" or not request("email2") like "%@%" then
response.write "<span class=""whitebox500""><br>THIS DOES NOT APPEAR TO BE A PROPER EMAIL ADDRESS."

response.write "<br><br><Br><input type=button onClick=""javascript:history.back(-1);"" value=""Back to Signup <<""><br><br>"
response.end
end if

and want to wildcard test the request to see if it is properly formatted email with an @ and a dot.

Two Insert Statements
Can i have 2 insert statements in my code inserting data in different tables.

So after i hit submit,the date should go and reside in particular tables.is it possilble?>and if yes..how do i do..any examples /links you can pass me?

IF Statements To Update Database
I need help with fixing my code below. It doesn;t work correctly. It works fine when there are 4 featured records. But I want to be able to change one to not be featured (equal to 0). This is not possible with my current code. It shows the same message about me not being able to have more than 4 featured records. Can someone please help me with this?

Code: ....

If Statements And Subs Problem With End IF
I am trying to get a page that loads up a different include file depending on which input form button was clicked.

I can get it to work with just one if statement but once I put a second if statement in I get the following error

Quote: Error Type:
Microsoft VBScript compilation (0x800A03F6)
Expected 'End'
/ordersearch/ordersearchresults.asp, line 27

Now no matter where I have though of putting my end if the page now doesn�t work. Does anyone know of the solution??? Code:

Using If, ElseIf Statements In Form
I have the folowing code for outputting the contens of a form to an e-mail. I am using AspEmail: PHP Code:

if attend="No" then Mail.Body = ("1")

elseif (attend="Yes" & guest="No") then Mail.Body = ("2")

else Mail.Body = ("3")

end if 

In other words, the e-mail being sent has 3 different formatted options.

Is this going to work, if not, can anyone suggest a work-around?

RS.open Statements Fundamentals
Can someone please direct me to an extensive guide on record set instruction statements and their uses? I do not really understand the diff between:

RS.Open SQLstmt, Conn, 2, 3
'RS.Open SQLstmt, Conn, adOpenKeyset, adLockOptimistic, adCmdText

But, when I use the one above in red during a record update I get the following error message:

ADODB.Recordset (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

Passing Variables In SQL Statements
I'm working on a Calendar for my FrontPage web. I've been struggling interminably to write an SQL statement that only calls records based on a variable (today's date, in YYYYMMDD format).

Here's how I've declared the variable:

var mytext = (document.clock.thedate.value)

So now I write my SQL statement:

"SELECT * FROM cal_db WHERE Num_date = '" & Request.QueryString("mytext") & "'"

I know the query string is valid, since I can successfully execute a document.write command that correctly writes the string to my web page. But when I run the SQL, no results are returned.

Select A Bunch Of Statements
I want to select a bunch of records where a certain field is equal to the following.
Code:

if game <> "" thensql = "SELECT DISTINCT game, system FROM wallpaper WHERE system = 'ps2' AND system = 'gba' AND system = 'gf' AND system = 'xbox' AND system = 'xbox360' AND system = 'gba' AND system = 'ds' AND system = 'pc' AND system = 'psp' AND system = 'ps3' ORDER by ID DESC LIMIT 0, 10"
Set rschanmedia = Server.CreateObject("ADODB.Recordset")
rschanmedia.Open sql, conn, 3, 3

The script works fine but when I run it it doesn't display any records at all! Yet when I run a script where system is <> to something it works fine! What's wrong?

Problem With Using Multiple If Statements...
I use one of the first two if statements by themselves, and comment everything else out, the code works. But when I use more than one of these, i get a "page cannot be displayed" message.

I've also tried condensing if statements into ifelses. Same results. Anyone know why this would be happening? Code:

GetRows And Insert/Select Statements
I'm using an SQL statement like the following:

Code:

INSERT INTO table (field) VALUES (value) SELECT @@IDENTITY AS NewIdent;

If I run it through a command prompt (osql.exe) it works fine - it inserts the data and returns the new identity. However, when I try to pass this through my nifty GetRows() function the stupid thing chokes (it acts like a normal INSERT statement has been passed - "ADODB.Recordset (0x800A0E78) Operation is not allowed when the object is closed." on the line where I try to execute GetRows).

I've looked through my ADO documentation and don't see any reason why this should be happening (since it does return data). Due to the small amount of data, I'm going to just use a plain old RecordSet object, but for my own piece of mind does anyone know why it won't treat the returned @@IDENTITY variable like normal data?

Include Statements - Virtual Files
I am still writting VBScript code and .asp pages for our Intranet. Recently I learned how to use include files from this site.

I was very successful using include statements as long as I put the include statement inside the subdirectory that contained the asp files I was using.

I would like to put the include files in the root or a seperate directory and be able to call them from a page tghat is in a different directory?

IE Displaying Empty Space For If Statements?
I have a form that submits to itself that also has some if statements. Sort of like this:

If the form is filled out successfully > display X
If not > list errors and replicate form (remembering entered values)
Form

Everything works beautifully, but I just noticed that there is a huge space at the top of my page in IE. Usually use FF, which displays fine, so never noticed this problem. If I take out the 'if' statements the space goes away.... so its like IE is leaving space for the if statements which should be hidden when the page is first loaded. Code:

Send Batch Of Sql Statements To Sql Server
how to go about sending a batch of sql statements from asp to sql server, and
having errors appropriately handled? for example,

i want to send the following stored procedure calls to sql server in a
single batch from my asp code, rather than using a loop in asp to execute
each procedure individiually. if one of these fails, they all should fail.

exec myProc @param1 = 'A'
exec myProc @param1 = 'B'
exec myProc @param1 = 'C'
exec myProc @param1 = 'D'
exec myProc @param1 = 'E'
exec myProc @param1 = 'F'

Trapping Mssql Raiserror Statements
I am inserting a record in a table(Trans_Master) using ado recordeset.I have also created trigger on the same table after INSERT where RollBack transaction is done when a condition is not met.

the created trigger is working fine.But the problem I am having is How do I can trap thus rollback in asp.One posssile solution I may see is traping raiserror in asp but don't know HOW?

Using Form Field Names In If Statements
I tried posting this a minute ago but timed out, so sorry if this is posted twice.
I want to make an IF statement in ASP using VBscript that will run if a checkbox in a form is checked (and won't otherwise). How do i refer to the form field (checkbox) in the IF statement to do this?

Question On String Comparison In SELECT Statements
question on string comparison in SELECT statements

--------------------------------------------------------------------------------

First off, this is not the standard problem that can be solved by using:

SELECT * FROM table WHERE string LIKE '%abcd%'

It's actually sort of the opposite of that. I'm looking for a query that can take a string variable and will return only rows where the complete string in the relevant column is a string of the variable passed to the query. So for instance, if the variable passed was 'abcd' then...

rows containing only these strings in the relevant column would be returned:

'abcd'

rows containing these strings in the relevant column would NOT be returned:
'abcdefg'
'abcdxyz'
'abcd1234'
'abcde'
'af'
'hijk'

Is there a way to do this with a MySQL query?

Thanks in advance.

ASP Inserting (')
There i seem to be having a problem when inserting certain characters into my access database using a form, mainly (') characters.

Inserting Into
I get the following error message

Microsoft VBScript compilation error '800a03ee'

Expected ')'

/weblinkup/chat.asp, line 1775

oConn.Execute("INSERT into chat (username,nametext,roomname,type,priv,thetime,msg) VALUES ('" & username & "', '" & username & "', '" & Roomname & "', 'msg', '0', '" & now() & "', '" & username & " has just said " & emotetarget & "." ')")

what the problem is with the code?

Bulk Inserting
I have an error as follows:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]Could not bulk insert. File 'c:mydata.csv' does not exist.

My mydata.csv file is inside the directory i stated. But why does the server complains that the file is not fould?

My codings:

strSQL = "BULK INSERT NAME FROM 'c:mydata.csv' WITH (FIELDTERMINATOR = ',',ROWTERMINATOR =

'
')"

Response.Write ("test")
Set oRS = conn.Execute(strSQL)

Inserting Database
I had some Error when i write the update sqlp query


Error Type:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/fyp/Quiz/updateQuiz.asp, line 21, column 77
SQL_query= "update Activity_Status set UserID = '" +Request.Form("username") "'" "where Score = '" +Request.Form("QuizScore" + "'")"


Code:
SQL_query= "update Activity_Status set UserID = '" +Request.Form("username") "'" "where Score = '" +Request.Form("QuizScore" + "'")"

Inserting Data
I'm wondering if it's possible to create an instance of an ADO Recordset and add values to it by ASP ??

Ex :
I have 2 arrays :
arr1 = Array(1,"allo")
arr2 = Array(2,"bonjour")

Is it possible to add these 2 arrays into a Recordset to manipulate de data more easily?
If yes, could you provide me with a little example to see the synthax, because I tried almost everything and it didn't worked at all

Inserting Smilies
how do i design my site interface such that users can insert smilies along with text in the form field just like it is here on sitepoint...


Copyright © 2005-08 www.BigResource.com, All rights reserved