Results 1 to 15 of 15

Thread: Please help re: data input/save

  1. #1

    Thread Starter
    Hyperactive Member vbuser1976's Avatar
    Join Date
    Sep 2000
    Location
    Yonkers, NY
    Posts
    404

    Unhappy

    Hi everybody!

    I need your help. I have created a table in the asp form attached to this thread called task list. Basically, for each project, there will be multiple people assigned to a specific task(project Id number should stay the same). I need code that would:

    1. Save multiple rows, i.e. for loop or while loop
    2. Stop saving rows if there is no information in it

    Each row will be a separate set of record but linked by the Project Id number. Can arrays do this? If so, how?

    Any ideas/suggestions? Thanks in advance
    Attached Images Attached Images  
    -vbuser1976
    VB6 Enterprise SP6
    SQL 7.0 SP2
    VBScript, HTML, Javascript, C++, a little UNIX

  2. #2
    are you getting the data from a database? or where? or what? or... just be more specific...

    i don't quite understand what u want to do but... it might be something like this.

    Code:
    dim field1
    dim field2
    Response.Write("<table>")
    Do
    Response.Write("<tr><td>" & field1 & "</td><td>" & field2 & "</tr>")
    'I called it GetNextField because i don't know how you are getting your data, wether it is an array etc.
    field1 = GetNextField()
    Loop While Trim(field1) <> 0
    Response.Write ("</table>")
    this is just a concept and i am not really sure what you are talking about.
    *urp*

  3. #3

    upon further reading...

    ok, i now understand what you are doing. what i would withing the row of the project ID, have a string that stores all the names, seperated by commas. and then when you need to call that list out of the database you can go ahead and split it up.

    i think thats what you meant. you might also consider doing this... having another table in your database where you store user information. when you click on the project ID the asp script calls up the user database and prints out a list of who has the projectID in their current projects.
    so it would be like...
    Code:
    if instr(activeprojects,projectID) > 1 then response.write(username)
    now thats one fricken confusing mess.
    *urp*

  4. #4

    Thread Starter
    Hyperactive Member vbuser1976's Avatar
    Join Date
    Sep 2000
    Location
    Yonkers, NY
    Posts
    404

    Question Hmm...

    First of all I would like to say welcome to the forums.

    Now, regarding your posts, if the project is new, then it is not getting any information from the database. I already created the second table for the database that would have all of the information needed.

    Let me explain in a little more detail what I am trying to do. I have a asp form page that is using html code to create the table(since the html table is static). If you look at the attachment that is part of the first post, you will see the table. Now I need to know that if I use a for loop to populate the table, if there is anything in the database, how do I go about it? Does each field in a column need to have the same name? Also I want it to leave rows empty if there is not data available. Would rs.movenext work in this? I hope this helps you to better understand what I am trying to do.

    Thanks again in advance for your help.
    -vbuser1976
    VB6 Enterprise SP6
    SQL 7.0 SP2
    VBScript, HTML, Javascript, C++, a little UNIX

  5. #5
    Guest
    Okay, forgive me if I'm getting you wrong, but from how I read it, you want something like this:

    First, you get the data from the database and put in a recordset we will call RS_Data, using something like '"select TaskDescription, Priority, AssignedTo, DueDate, Status, Comments from TABLE where ProjectID = " & numProjectID', where numProjectID is the ID of the project you wanna get the data for.

    Then, you go something like this:

    =========================================

    <table>
    <tr>
    <td>Task Description</td>
    <td>Priority</td>
    <td>Assigned To</td>
    <td>Due Date</td>
    <td>Status</td>
    <td>Comments</td>
    </tr>
    <%
    do while not RS_Data.EOF
    response.write("<tr>")
    response.write("<td>" & RS_Data("TaskDescription")) & "</td>")
    response.write("<td>" & RS_Data("Priority")) & "</td>")
    response.write("<td>" & RS_Data("AssignedTo")) & "</td>")
    response.write("<td>" & RS_Data("DueDate")) & "</td>")
    response.write("<td>" & RS_Data("Status")) & "</td>")
    response.write("<td>" & RS_Data("Comments")) & "</td>")
    response.write("</tr>")
    RS_Data.Movenext
    loop
    %>
    </table>

    =========================================

    If you wanna check if the fields are empty first, before displaying their value, you could go something like:

    =========================================

    ....
    <%
    do while not RS_Data.EOF
    response.write("<tr>")
    if not IsNull(RS_Data("TaskDescription")) then
    response.write("<td>" & RS_Data("TaskDescription")) & "</td>")
    else
    response.write("<td></td>")
    end if
    if not IsNull(RS_Data("Priority")) then
    response.write("<td>" & RS_Data("Priority")) & "</td>")
    else
    response.write("<td></td>")
    end if

    etc, etc..

  6. #6

    Thread Starter
    Hyperactive Member vbuser1976's Avatar
    Join Date
    Sep 2000
    Location
    Yonkers, NY
    Posts
    404

    Talking Just a quick question...

    Hi MarcelB!

    Thanks for your reply. My question is this: If the table was already created using the html code (because it needs to be static), do I still have to use the<td> and <tr>? If not, how do I make sure that the data is going to the right column/row?

    I hope this isn't confusing.
    -vbuser1976
    VB6 Enterprise SP6
    SQL 7.0 SP2
    VBScript, HTML, Javascript, C++, a little UNIX

  7. #7
    Guest
    If the <table> and </table> tags are already there, you can just leave those out of the code I wrote. If there are already other rows of data in that table, you might want to use something like what I wrote below.

    If not, then don't even bother.

    =========================

    <tr>
    &nbsp;<td colspan="x">&nbsp;&nbsp;(x being the number of td's used per row before)
    &nbsp;&nbsp;<table>

    (code from before, withouth the <table> and </table> tags)

    &nbsp;&nbsp;</table>
    &nbsp;</td>
    </tr>

    =========================

  8. #8

    Thread Starter
    Hyperactive Member vbuser1976's Avatar
    Join Date
    Sep 2000
    Location
    Yonkers, NY
    Posts
    404

    Cool Thanks!

    thanks for all your replies! I will try all of your suggestions out.
    -vbuser1976
    VB6 Enterprise SP6
    SQL 7.0 SP2
    VBScript, HTML, Javascript, C++, a little UNIX

  9. #9

    Thread Starter
    Hyperactive Member vbuser1976's Avatar
    Join Date
    Sep 2000
    Location
    Yonkers, NY
    Posts
    404

    Unhappy Ok...

    It looks like the populating of the table is working. But, How do I save the changes or additions to the table? I know about rs.update but I need to know how I save this stuff. Thanks for all you help. I hope this isn't confusing.
    -vbuser1976
    VB6 Enterprise SP6
    SQL 7.0 SP2
    VBScript, HTML, Javascript, C++, a little UNIX

  10. #10
    Guest
    Okay, so you sorta wanna use it like a grid in VB?

    Well, what you could do is put the table on a form, and then when you leave the page (and wanna save the data), is read out the data in the different input fields, and then update the table for every row. To do this, you would also need to keep track of the ID for each row of data (for instance by putting it in a hidden input field).

    But I bet there are easier ways to do this, but I don't know of any, so someone else please help!?

  11. #11

    Thread Starter
    Hyperactive Member vbuser1976's Avatar
    Join Date
    Sep 2000
    Location
    Yonkers, NY
    Posts
    404

    Cool FINALLY!

    finally, someone understood what I am trying to do. Yeah, I do want it to work like a grid in VB. But I do need some sample code to understand what you are trying to say, MarcelB. I have an idea of what you are trying to say, but I am not sure.

    Thanks again for your enormous help. And, if you know of anyone that might have an idea as well, you can forward this thread.
    -vbuser1976
    VB6 Enterprise SP6
    SQL 7.0 SP2
    VBScript, HTML, Javascript, C++, a little UNIX

  12. #12
    Guest
    Okay, well, let's wait if someone else knows an easier way and posts that. If not, I'll send you some sample code tomorrow, okay? Maybe it's easier (and less poluting to the forum) to do that through e-mail then.

  13. #13

    A SAMPLE.

    this is something i created. its a bit messy cause it was my first database.

    it has some imput fields if thats what you want.
    Code:
    if Request.QueryString("dept") = "MIS" or Request.QueryString("dept") = "ALL" then
    	Response.Write("<tr><td bgcolor=#000000 colspan=2 height=1> </td></tr>" & chr(13))
    	Response.Write("<tr><td colspan=2 bgcolor=#9999DD><font size=2><b><div align=center>MIS</div></b></font></td></tr>")	
    	Response.Write("<tr><td bgcolor=#000000 colspan=2 height=1> </td></tr>" & chr(13))
    	strQuery = "SELECT transtype, DEL_emailaccount, DEL_networkaccount, DEL_userfolder, last_name, first_name, start_date, initials, social, MIS_login_id, MIS_login_password, MIS_email_password, MIS_default_server, MIS_internet_address, MIS_rightfax, MIS_notes_requested, MIS_notes_received, MIS_notes_pass, comments, MIS_date_comp"
    	strQuery = strQuery & " FROM " & Request.QueryString("office") & " WHERE id = " & Request.QueryString("id")
    	Set objRS = objConn.Execute(strQuery)
    	While Not objRS.EOF
    	transtype = objRS("transtype")
    	If transtype = "TERM" then
    		Response.Write("<tr><td bgcolor=#AAAAFF colspan=2><div align=center><font size=2><b>DELETED</b></font></div></td></tr>")
    		checked = ""
    		if objRS("DEL_networkaccount") = "del" then checked = " checked"
    		Response.Write("<tr><td colspan=2 bgcolor=#FFFFFF><font size=2><input type=checkbox name=DEL_networkaccount value=del" & checked & "> Deleted Network Account</font></td></tr>")
    		checked = ""
    		if objRS("DEL_emailaccount") = "del" then checked = " checked"
    		Response.Write("<tr><td colspan=2 bgcolor=#FFFFFF><font size=2><input type=checkbox name=DEL_emailaccount value=del" & checked & "> Deleted Email Account</font></td></tr>")
    		checked = ""
    		if objRS("DEL_userfolder") = "del" then checked = " checked"
    		Response.Write("<tr><td colspan=2 bgcolor=#FFFFFF><font size=2><input type=checkbox name=DEL_userfolder value=del" & checked & "> Deleted User Folder</font></td></tr>")	
    	else
    	Response.Write("<tr><td bgcolor=#AAAAFF colspan=2><div align=center><font size=2><b>NETWORK</b></font></div></td></tr>")
    	Response.Write("<tr><td bgcolor=#FFFFFF><font size=2><b>Login ID:</b></font></td><td bgcolor=#FFFFFF><input type=text name=MIS_login_id value=""" & ObjRS("MIS_login_id") & """></td></tr>" & chr(13))
    	Response.Write("<tr><td bgcolor=#FFFFFF><font size=2><b>Login Password:</b></font></td><td bgcolor=#FFFFFF><input type=text name=MIS_login_password value=""" & ObjRS("MIS_login_password") & """></td></tr>" & chr(13))
    	Response.Write("<tr><td bgcolor=#FFFFFF><font size=2><b>Default Server:</b></font></td><td bgcolor=#FFFFFF><input type=text name=MIS_default_server value=""" & ObjRS("MIS_default_server") & """></td></tr>" & chr(13))	
    	Response.Write("<tr><td bgcolor=#AAAAFF colspan=2><div align=center><font size=2><b>EMAIL</b></font></div></td></tr>")
    	Response.Write("<tr><td bgcolor=#FFFFFF><font size=2><b>Email Address:</b></td><td bgcolor=#FFFFFF><input type=text name=MIS_internet_address value=""" & ObjRS("MIS_internet_address") & """></td></tr>" & chr(13))
    	Response.Write("<tr><td bgcolor=#FFFFFF><font size=2><b>Email Password:</b></td><td bgcolor=#FFFFFF><input type=text name=MIS_email_password value=""" & ObjRS("MIS_email_password") & """></td></tr>" & chr(13))
    	Response.Write("<tr><td bgcolor=#AAAAFF colspan=2><div align=center><font size=2><b>NOTES</b></font></div></td></tr>")
    	Response.Write("<tr><td bgcolor=#FFFFFF><font size=2><b>Requested:</b></td><td bgcolor=#FFFFFF><input type=text name=MIS_notes_requested value=""" & ObjRS("MIS_notes_requested") & """></td></tr>" & chr(13))
    	Response.Write("<tr><td bgcolor=#FFFFFF><font size=2><b>Received:</b></td><td bgcolor=#FFFFFF><input type=text name=MIS_notes_received value=""" & ObjRS("MIS_notes_received") & """></td></tr>" & chr(13))
    	Response.Write("<tr><td bgcolor=#FFFFFF><font size=2><b>Password:</b></td><td bgcolor=#FFFFFF><input type=text name=MIS_notes_pass value=""" & ObjRS("MIS_notes_pass") & """></td></tr>" & chr(13))
    	Response.Write("<tr><td bgcolor=#AAAAFF colspan=2><div align=center><font size=2><b>OTHER</b></font></div></td></tr>")
    	Response.Write("<tr><td bgcolor=#FFFFFF><font size=2><b>RightFax Number:</b></td><td bgcolor=#FFFFFF><input type=text name=MIS_rightfax value=""" & ObjRS("MIS_rightfax") & """></td></tr>" & chr(13))
    	end if
    	Response.Write("<tr><td bgcolor=#FFFFFF><font size=2><b>Date Completed:</b></td><td bgcolor=#FFFFFF><input type=text name=MIS_date_comp value=""" & objRS("MIS_date_comp") & """></td></tr>" & chr(13))
    	objRS.MoveNext
    	Wend
    	objRS.close
    	set objRS = Nothing
    end if
    and i have a the table tags around that... its such a mess because there are soo many options, i wish i had a simpler version for you (believe it or not, i cut out a couple if statements)
    *urp*

  14. #14
    Guest
    Correct me if I'm wrong, but I think that part was clear to him by now. I think it's the updating of the fields from the page back into the database that he'd like an example of, right?

  15. #15
    yea, i know whats up, and we chatted and it was cleared up, and we have attacked the problem.
    *urp*

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width