There's something wrong i still get the word Test
even though i deleted it....??
There's something wrong i still get the word Test
even though i deleted it....??
did you refresh (F5)?
Also, in IE, with IIS, you should set IE to change the page every time:
IN IE, go to TOOLS menu, select OPTIONS
Click on the GENERAL tab, then click on the SETTINGS button
there are 4 choices about checking for new page:
Click the first one:
EVERY VISIT TO THE PAGE
That will force IE to show the changes every time
Ok, i put it in Every visit to ....
But i now i get this:
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'skill'.
/test.asp, line 9
on the other question, you have to put some data in these controls to show the data
for example, in your textarea, you could load some text:
<p>Description:
<textarea name="comp-desc" cols="45" rows="2" id="comp-desc">THE TEXT GOES HERE</textarea>
or from a recordset:
<%
SET rs=CreateObject("ADODB.Recordset")
sql="select Top 1 * from MYTABLE"
rs.Open sql,Conn,1,2
%>
<textarea name="comp-desc" cols="45" rows="2" id="comp-desc"><%=rs("somefield")%></textarea>
To populate a select box, you loop thru the records as I posted in #40:
<%
SET rs=CreateObject("ADODB.Recordset")
sql="select * from MYTABLE"
rs.Open sql,Conn,1,2
%>
<select name="whatever">
<%do until rs.eof%>
<option value="<%=rs("id")%>"><%=rs("somefield")%></option>
<%rs.movenext
loop%>
</select>
That means you have no column named 'Skill'
So tell me the name of the table and the data fields you are trying to show.
ok The name of the table is: Skills
columns: skill-num, skill-name, created-date,last-update-date
those are it
OK. if you have some data, can be shown like this:
<table width="75%" align="center" bgcolor="#c0c0c0" cellspacing="1">
<tr>
<td width="25%" align="center" bgcolor="#ffffff"><b>Number</b></td>
<td width="25%" align="center" bgcolor="#ffffff"><b>Name</b></td>
<td width="25%" align="center" bgcolor="#ffffff"><b>Created</b></td>
<td width="25%" align="center" bgcolor="#ffffff"><b>Updated</b></td>
</tr>
<%
SET rs=CreateObject("ADODB.Recordset")
sql="select * from Skills Order by Created-date ASC"
rs.Open sql,Conn,1,2
do until rs.eof
%>
<tr>
<td width="25%" align="center" bgcolor="#ffffff"><%=rs("skill-num")%></td>
<td width="25%" align="center" bgcolor="#ffffff"><%=rs("skill-name")%></td>
<td width="25%" align="center" bgcolor="#ffffff"><%=rs("created-date")%></td>
<td width="25%" align="center" bgcolor="#ffffff"><%=rs("last-update-date")%></td>
</tr>
<%rs.movenext
loop%>
</table>
That's it
Nop
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'Created'.
/test.asp, line 16
Do i show you the code??
What time is it over there?
can you post your whole ASP page code here and show me which is line 16?
by the way, i think it is no good to use - in your field names, causes some confusion
I dont understand it's not good to use my filed names?, i'm confused.
Ok here it is:
<!--#include File="conn.asp"-->
<html>
<body>
<table width="75%" align="center" bgcolor="#c0c0c0" cellspacing="1">
<tr>
<td width="25%" align="center" bgcolor="#ffffff"><b>Number</b></td>
<td width="25%" align="center" bgcolor="#ffffff"><b>Name</b></td>
<td width="25%" align="center" bgcolor="#ffffff"><b>Created</b></td>
<td width="25%" align="center" bgcolor="#ffffff"><b>Updated</b></td>
</tr>
<%
SET rs=CreateObject("ADODB.Recordset")
sql="select * from Skills Order by Created-date ASC"
rs.Open sql,Conn,1,2 ---------------------------------------LINE 16 *****
do until rs.eof
%>
<tr>
<td width="25%" align="center" bgcolor="#ffffff"><%=rs("skill-num")%></td>
<td width="25%" align="center" bgcolor="#ffffff"><%=rs("skill-name")%></td>
<td width="25%" align="center" bgcolor="#ffffff"><%=rs("created-date")%></td>
<td width="25%" align="center" bgcolor="#ffffff"><%=rs("last-update-date")%></td>
</tr>
<%rs.movenext
loop%>
</table>
</body>
</html>
OK
try this:
in SQL Server, change your field names:
skill-num, skill-name, created-date,last-update-date
to
SkillNum, SkillName, CreatedDate, LastUpdate
Then change my line 15 code:
sql="select * from Skills Order by Created-date ASC"
to:
sql="select * from Skills Order by CreatedDate ASC"
then change these 4 lines:
<td width="25%" align="center" bgcolor="#ffffff"><%=rs("skill-num")%></td>
<td width="25%" align="center" bgcolor="#ffffff"><%=rs("skill-name")%></td>
<td width="25%" align="center" bgcolor="#ffffff"><%=rs("created-date")%></td>
<td width="25%" align="center" bgcolor="#ffffff"><%=rs("last-update-date")%></td>
to:
<td width="25%" align="center" bgcolor="#ffffff"><%=rs("SkillNum")%></td>
<td width="25%" align="center" bgcolor="#ffffff"><%=rs("SkillName")%></td>
<td width="25%" align="center" bgcolor="#ffffff"><%=rs("createdDate")%></td>
<td width="25%" align="center" bgcolor="#ffffff"><%=rs("lastupdate")%></td>
and you will have a lovely table of data!
Yeeahhhh!!!!
You are great :-)
I do have a lovely table of data !!!!
You made my day, i hope yours is a wonderfull one also
Thanks for your help, i hope you'll check on me again, just in case i get lost (which i'll probably will)
Thanks,
Edith
all problems have at least one solution (and in programming have more than one)
Glad to help.
Hello,
How do i submit, save or delete the data from an ASP page?
I add new data to the table and now i want to be able to modify it, delete or add a new (for example) skill.
Hope you're there,
E
Well, tell me the data types of each field and I will help you with a sample code:
SkillNum - Int/Autonumber?
SkillName - VarChar/Text ?
and the other two are date/times?
Tell me those and I will help you build a model for this.
OK
SkillNum - Primary Key/nvarchar(text)
SkillName - Text
CreatedDate and lastUpdate - are datetime
OK, sorry, some questions to be clear:
Skillnum is a NVARCHAR, not an INTEGER? Is it a number?
I see that SkillNum is your Primary Key, is it supposed to be like an ID number? Is it unique?
Created Date means the date you entered the skill to database or a different date?
LastUpdate changes every time you edit the Skill?
Yeah i put SkillNum to be a nvarchar, but is a number. In the input mask i put it as a number, like this : 99999;; It's an ID, but i dont' want it to be forced, i want to be able to change it.
And yes created date means the day i entered the skill to the database.
About LastUpdate, it is supposed to change everytime i edit the skill, but i don't know how to do it so i'll just live the date as it is. So no it does not change.
I don't know a lot of things, but that's why I'm here. :-)
OK. I am making a model of this, will send it in a few minutes. You can try it.
Ok, thanks !!
This is the page TEST.ASP, just copy all and save it. Then run the page again. You can add new records as you like.
VB Code:
<!--#include File="conn.asp"--> <%'this is the save to database code when somebody enters a new data if Request.ServerVariables("REQUEST_METHOD") = "POST" then'already submitted sSkillName = request("skillname") 'here we can take what the user entered as skill name, put to a variable Set RS=CreateObject("ADODB.Recordset") sql="select * from Skills where SkillName = '" & sSkillname & "' or SkillNum = " & request("skillnum") Rs.Open sql,conn,1,3 If RS.eof then 'Just want to check if this skill name already exists in db before saving it rs.addnew 'make a new record rs("Skillname") = sSkillName 'the name entered by user rs("Skillnum") = request("skillnum") rs("CreatedDate") = Date 'that puts today's date rs("LastUpdate") = Date 'that puts today's date rs.update 'save the record else' it is already here, don't submit to db response.write "<p align='center'><font face='verdana' size='2' color='red'>The skill you entered, " & sSkillName & ", is already in the database, so it was not added.</font></p>" end if'if the skill is not already in db end if'submit data to db %> <html> <head> <script language="javascript"> function checkinput(){ //use this Javascript function to see what the user entered before submitting. if (newskill.skillname.value == "") {alert("You have to enter a skill name."); newskill.skillname.focus(); return false;} if (newskill.skillnumber.value == "") {alert("You have to enter a skill number."); newskill.skillnumber.focus(); return false;} if (IsNumeric(newskill.skillnumber.value) == false) {alert("The skill number must be a number."); newskill.skillnumber.focus(); return false;} } function IsNumeric(sText) { //this function checks if some text is a number or not if (sText.length > 1 && sText.charAt(0)=="0") { IsNumber = false; return IsNumber} var ValidChars = "0123456789"; var IsNumber=true; var Char; for (i = 0; i < sText.length && IsNumber == true; i++) { Char = sText.charAt(i); if (ValidChars.indexOf(Char) == -1) { IsNumber = false; } } return IsNumber; } </script> </head> <body> <%'here is the form to add new records!%> <form name="newskill" id="newskill" Method="Post" onSubmit="return checkinput();"> <table cellpadding="4" cellspacing="1" border="0" width="75%" align="center" bgcolor="000082"> <tr> <td height="37" colspan="2" bgcolor="#000082"><font face="verdana, arial, helvetica" size="2" color="#F0F0F0"><b>Adding a New Skill</b></font><font face="verdana,arial,helvetica" size="1" color="#F0f0f0">Here you add new skill records to the database.</font></td> </tr> <tr> <td width="55%" bgcolor="#DFDFDF"><font face="verdana, arial, helvetica" size="2" ><b>Skill Number</b><br> </font> <font face="verdana,arial,helvetica" size="1" >Enter a skill number (no decimals).</font></td> <td width="45%" align="center" bgcolor="#DFDFDF"><font face="verdana, arial, helvetica" size="2" > <input type="text" name="skillnum" id="skillnum" maxlength="10" size="10"> </font></td> </tr> <tr> <td width="55%" bgcolor="#DFDFDF"><font face="verdana, arial, helvetica" size="2" ><b>Skill Name</b><br> </font> <font face="verdana,arial,helvetica" size="1" >Enter a skill name (up to 30 characters).</font></td> <td width="45%" align="center" bgcolor="#DFDFDF"><font face="verdana, arial, helvetica" size="2" > <input type="text" name="skillname" id="skillname" maxlength="30" size="30"> </font></td> </tr> <tr bgcolor="#000082"> <td colspan="2"><font face="verdana, arial, helvetica" size="2" > </font></td> </tr> </table> <p align="center"><input type="submit" class="bginput" value="Submit"></p> </form> <%'end of add records form%> <%'here is where you show the records%> <table width="75%" align="center" bgcolor="#c0c0c0" cellspacing="1"> <tr> <td width="25%" align="center" bgcolor="#ffffff"><b>Number</b></td> <td width="25%" align="center" bgcolor="#ffffff"><b>Name</b></td> <td width="25%" align="center" bgcolor="#ffffff"><b>Created</b></td> <td width="25%" align="center" bgcolor="#ffffff"><b>Updated</b></td> </tr> <% SET rs=CreateObject("ADODB.Recordset") sql="select * from Skills Order by CreatedDate ASC" rs.Open sql,Conn,1,2 do until rs.eof %> <tr> <td width="25%" align="center" bgcolor="#ffffff"><%=rs("SkillNum")%></td> <td width="25%" align="center" bgcolor="#ffffff"><%=rs("SkillName")%></td> <td width="25%" align="center" bgcolor="#ffffff"><%=rs("createdDate")%></td> <td width="25%" align="center" bgcolor="#ffffff"><%=rs("lastupdate")%></td> </tr> <%rs.movenext loop%> </table> </body> </html>
let me know if it has errors, I can not run this without the database.
I think you are making a mistake in your db structure. If you want to use skillnum, enter the number yourself, and change it later, you should add a new Column, ID, and make that the Primary Key, auto increment. That way, you have a real, unique, permanent ID for each record, and you can change anything else.
Otherwise, later, maybe SQL Server will make an error when you want to edit one record, since it cannot confirm which record is being edited.
Ooohhh
Then i guess i'll have to do it to the rest of my tables. :-( I'll be here i while.
I did the copy/paste, and it worked perfect. !!!!
No errors :-)
Thank you again,
Edith
Be sure to read and understand all the code. The javascript will not allow the user to submit unless they enter the name and number. Then number must be numeric.
Then after submit, the query checks to see if the same name or number exists in the database, so it can't be added again.
The basic structure is <form method="post"><inputs></form>
then the other half is after the page reloads <% if method="post" %>
That's basically it for adding records.
When you feel comfortable with this code, you can go on to editing data. But like I said, you should have a permanent, increment ID for each record, so that SQL Server can find it. Remember, when you bring a recordset back to your page, you disconnect from the database. To save changes to the record, SQL Server has to find the same record in the database again. But if you change the number, which is the primary key, probably SQL Server cannot find that record again and you will get the error:
'this recordset cannot be updated'
So, add the ID field to your table, make it INT, set as Autoincrement, and set to Primary Key. Then you should change SkillNum to an INT field.
Also, if your Skill Name has a limited size, you should not use TEXT field. That is too big (2E16 !!). You should use VARCHAR and fix a limit (for example 50 characters)
Also, never use NVARCHAR. You don't need that. It is for unicode when you use languages like Chinese, Japanese. If you use English, just use varchar.
by the way, if you add the ID field, I think it is easier to add it just as INT first, not autoincrement. Then save the table design. Then open the table all records, and add the numbers 1,2,3, whatever to each record under ID. When every record has a unique ID, save that (re-execute the !). Then go back to table design and switch it to AUTOINcREMENT. This way will be no errors.
Wow, so i'll probably have to redo my tables, must of the field are text.
I'll do the ID, INT and re-execute it to put it in auto increment.
This is all new to me.
Thanks !!
OK. well, edit code is not difficult. When you are ready to do it, let me know. I'm going offline now, since it's pretty late here. Good luck.
ok, good night
Hello
I don't know if you check here first or some other place but anyway I put the msg here.
I have this syntax error and i can't see the data in my page.
<%
SET rs=CreateObject("ADODB.Recordset")
sql="select * from User Order by CreatedDate ASC"
rs.Open sql,Conn,1,2
do until rs.eof
%>
But i see no error
Plus in a new ASP i created when i enter the data and press submit it doesn't show the name, but everything else is visible. Weird.
Hope u answer :-)
This is the code of Comp - the one that i can't see the name:
<%
if Request.ServerVariables("REQUEST_METHOD") = "POST" then
sCompName = request("sCompName")
Set RS=CreateObject("ADODB.Recordset")
sql="select * from Competency where CompName = '" & sCompName & "' or CompNum = " & request("CompNum")
Rs.Open sql,conn,1,3
If RS.eof then
rs.addnew
rs("CompName") = sCompName
rs("CompNum") = request("CompNum")
rs("CompName") = request("CompName")
rs("CompDesc") = request("CompDesc")
rs("CompProcowner") = request("CompProcowner")
rs("CompSystowner") = request("CompSystowner")
rs("CreatedDate") = Date
rs("LastUpdate") = Date
rs.update
else
response.write "<p align='center'><font face='verdana' size='2' color='red'>The comp you entered, " & sCompName & ", is already in the database, so it was not added.</font></p>"
end if
end if
%>
<html>
<head>
<script language="javascript">
function checkinput(){
//use this Javascript function to see what the user entered before submitting.
if (newcomp.CompName.value == "")
{alert("You have to enter a Comp name.");
newcomp.CompName.focus();
return false;}
if (newcomp.CompDesc.value == "")
{alert("You have to enter a Comp desc.");
newcomp.CompDesc.focus();
return false;}
if (newcomp.CompProcowner.value == "")
{alert("You have to enter a Comp proc name.");
newcomp.CompProcowner.focus();
return false;}
if (newcomp.CompSystowner.value == "")
{alert("You have to enter a Comp system name.");
newcomp.CompSystowner.focus();
return false;}
if (newcomp.compnumber.value == "")
{alert("You have to enter a skill number.");
newcomp.compnumber.focus();
return false;}
if (IsNumeric(newcomp.compnumber.value) == false)
{alert("The skill number must be a number.");
newcomp.compnumber.focus();
return false;}
}
function IsNumeric(sText)
{
//this function checks if some text is a number or not
if (sText.length > 1 && sText.charAt(0)=="0")
{ IsNumber = false;
return IsNumber}
var ValidChars = "0123456789";
var IsNumber=true;
var Char;
for (i = 0; i < sText.length && IsNumber == true; i++)
{
Char = sText.charAt(i);
if (ValidChars.indexOf(Char) == -1)
{
IsNumber = false;
}
}
return IsNumber;
}
</script>
</head>
<body>
Don't know how but i fixed the code and now i can see the name.
But the syntax error it's still not visible.
<table width="75%" align="center" bgcolor="#c0c0c0" cellspacing="1">
<tr>
<td width="25%" align="center" bgcolor="#ffffff"><b>Number</b></td>
<td width="25%" align="center" bgcolor="#ffffff"><b>Name</b></td>
<td width="25%" align="center" bgcolor="#ffffff"><b>Last Name</b></td>
<td width="25%" align="center" bgcolor="#ffffff"><b>Roles</b></td>
<td width="25%" align="center" bgcolor="#ffffff"><b>Email</b></td>
<td width="25%" align="center" bgcolor="#ffffff"><b>Created</b></td>
<td width="25%" align="center" bgcolor="#ffffff"><b>Updated</b></td>
</tr>
<%
SET rs=CreateObject("ADODB.Recordset")
sql="select * from User Order by CreatedDate ASC"
rs.Open sql,Conn,1,2
do until rs.eof
%>
<tr>
<td width="25%" align="center" bgcolor="#ffffff"><%=rs("NtID")%></td>
<td width="25%" align="center" bgcolor="#ffffff"><%=rs("UserFirstName")%></td>
<td width="25%" align="center" bgcolor="#ffffff"><%=rs("UserLastName")%></td>
<td width="25%" align="center" bgcolor="#ffffff"><%=rs("UserRoles")%></td>
<td width="25%" align="center" bgcolor="#ffffff"><%=rs("UserEmail")%></td>
<td width="25%" align="center" bgcolor="#ffffff"><%=rs("CreatedDate")%></td>
<td width="25%" align="center" bgcolor="#ffffff"><%=rs("LastUpdate")%></td>
</tr>
<%rs.movenext
loop%>
</table>
so what is the error? is there an error message? do you mean your data is not visible?
by the way, your table has 7 25% widths, that means your table is 175% wide.
Maybe adjust each width according to which data is larger, but usually, the total width of the text divisions <td> should not be more than 100%.
Of course this is not the reason for any code problem, but just an aesthetic tip.
Good morning,
Ooohh, right, change the number to a 25%.
The page user.asp gives me an incorrect syntax error near the keyword "User". The page doesn't show the data, not visible.
But i checked the whole code and i wrote the "keyword User" correct. I use the Find
and replace.
Thanks for your help ...
so, I'm not clear. do you still have a problem? if so, what is it?
:-)
Yes, the problem is that i can't see the user.asp
I use the code you gave me and modify it so i could see the user info. But when i open the page is not visible, there is an error, an Incorrect syntax near the keyword 'User'.
So i tried to use the Find and Replace to see if i really wrote it wrong but its right,. so i don't know what's his problem (the PC i mean)
I now added this columns:
rs("NtId") = sNtID
rs("UserFirstName") = request("UserFirstName")
rs("UserLastName") = request("UserLastName")
rs("UserRoles") = request("UserRoles")
rs("UserEmail") = request("UserEmail")
rs("CreatedDate") = Date
rs("LastUpdate") = Date
The problem line is this one:
<%
SET rs=CreateObject("ADODB.Recordset")
sql="select * from UserTbl Order by CreatedDate ASC"
rs.Open sql,Conn,1,2
do until rs.eof
%>
Ok, ???
You know i re-did it and put it in a new table and know its visible... i think that the word "User" can't be used.
can you paste your whole page code and also the error exactly?
Before u go
What if a have UserTbl join to UserTraining (both tables) With the same primary key NtID. Do i have to change one of the primary keys?
The one with the word User??