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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Primary Key issues--Please Help 3

Status
Not open for further replies.

kelfuego

MIS
Jun 5, 2002
74
0
0
US
Hello all, I am having a difficult time entering new information into a SQL Database that I have setup. My conneciton strings work fine, but I'm hanging up on my primary key. below is the code and the error that I'm recieving. Can someone help a rookie out ?


Code----------------------------

<% dim pkey
set pkey = year(now) & month(now) & day(now) & minute(now) & second(now) %>

<input name="txtid" type="text" id="txtid" value="<%pkey%>">


Error--------------------------

Microsoft VBScript runtime error '800a01a8'

Object required: '[string: "200454142830"]'




Kelly Johnson MCP
Volunters of America Oregon
 
in your last line of code try:

<input name="txtid" type="text" id="txtid" value="<%=pkey%>">


You are missing an equals sign.
 
Thank you but that did not correct the issue


Kelly Johnson MCP
Volunters of America Oregon
 
Please post the code you use to add the record to your database.
 
As requested here is my insert code


<form name="form1" method="POST" action="<%=MM_editAction%>">
<table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr>
<td><strong>1. Please Enter the Date your training took place:
<input name="txtid" type="text" id="txtid" value="<%=pkey%>">
</strong></td>
</tr>
<tr>
<td height="33"><input name="txtDate" type="text" id="txtDate"></td>
</tr>
<tr>
<td height="31"><strong>2. Which Program do you work In?:</strong></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><strong>3. <font color="#006600"><%=(Recordset1.Fields.Item("Question1").Value)%></font></strong></td>
</tr>
<tr>
<td><textarea name="txtAns1" cols="75" rows="7" id="txtAns1"></textarea></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><strong>4.<font color="#006600"><%=(Recordset1.Fields.Item("Question2").Value)%></font></strong></td>
</tr>
<tr>
<td><textarea name="txtAns2" cols="75" rows="7" id="txtAns2"></textarea></td>
</tr>
<tr>
<td><strong>5. <font color="#006600"><%=(Recordset1.Fields.Item("Question3").Value)%></font></strong></td>
</tr>
<tr>
<td><textarea name="txtAns3" cols="75" rows="7" id="textarea2"></textarea></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><strong>6. <font color="#006600"><%=(Recordset1.Fields.Item("Question4").Value)%></font></strong></td>
</tr>
<tr>
<td><textarea name="txtAns4" cols="75" rows="7" id="textarea3"></textarea></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><strong>7.</strong> <strong><font color="#006600"><%=(Recordset1.Fields.Item("Question5").Value)%></font></strong></td>
</tr>
<tr>
<td><textarea name="txtAns5" cols="75" rows="7" id="textarea4"></textarea></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td> <p>
<input type="submit" name="Submit" value="Submit">
</p>
<p>
<%response.write pkey %>
</p></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
</table>
<p>&nbsp; </p>
<p>&nbsp; </p>
<input type="hidden" name="MM_insert" value="form1">
</form>


Kelly Johnson MCP
Volunters of America Oregon
 
First problem, when setting a variable value, do not use Set. Set is only used to set a variable equal to an object reference (for example, a recordset object, a connection objectm, a RegularExpression object). Changing the value of a variable (string, number, date, etc) only needs an assignment, ie just variable = value.

Second Problem, you haven't gotten this error yet but after you clear up the firat problem your next one is goig to be that you don't have a value in your input. lovejaeeun has shown you the solution to that problem. Basically you need to write the value using Response.Write. Doing <%=variable%> is a shortcut for <%Response.Write variable%>.


I believe the object error should be corrected by the first section. In this case the error in English is saying: I tried to do the assignment, but you gave me a string instead of the object I was expecting to have (due to the Set in that line).

Hope that clears it up,
-T

[sub]01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111[/sub]
The never-completed website:
 
I want to thank both of you for your help. Both posts indeed answered my issue. The last post was extra helpful and I appreciate the explanation provided. So not only have I resolved the issue, but also learned a little bit along the way.



Kelly Johnson MCP
Volunters of America Oregon
 
Thats what we're here for [thumbsup]

Glad to be of assistance,

-T

[sub]01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111[/sub]
The never-completed website:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top