Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 Other Topics
 question

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-05-02 : 15:06:56
sschua writes "I am very new in vb and sql server. Now I get the project to create the form. It is the purcharse invoice form. This form want to add multiple records at one time. It means that user
can enter multiple purcharse details at one time.

My problem is when user want to enter the purcharse detail. Sometime there are many items in one purcharse invoice and I want to know the how to control to add many records at one time using store procedure.. and where can i find the sample code, just for my references.......

and how to make the purcharse invoice no. to run automatically after i save the data to database......

Pls reply as soon as possible. Becoz my due date is coming near and near


thank you"

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2002-05-02 : 22:16:55
I can't tell you how you SHOULD do it, but I can tell you how I do it. I have exactly the same situation, and my site runs very nicely, thankyou. You may want to follow up with subsequent questions...so feel free.

Here's the short form

step 1, html form with xml object which contains defaults for the PO.

eg
<xml id = 'POForm'>
<header>
<suppliername/>
<costcode/>
<deliveryaddress>1 main road nowhere</deliveryaddress>
</header>
<detail>
<line>1</line>
<description/>
<price>$0.00</price>
</detail>
</xml>

next bind the xml object to an html table - (I'll leave that for you), add button to add or delete detail lines

create a "submit" button which does all your validity checking - PS don't use a "submit" button as such, and don't set your html form action, just create a button and to the following javascript:

oXMLHTTP.open("POST", "SubmitPurchaseOrder.asp", false);
oXMLHTTP.send(dsoFORM.XMLDocument); strResponse = oXMLHTTP.responseText;
document.all("data").innerHTML = strResponse
etc

In you "SubmitPurchaseOrder.asp" page, loop through each detail line and build an "insert" SQL statement, inserting your single lines 1 at a time, into a "pending" table.

As a last step, call a stored procedure that inserts all records from the pending table into your real table in one go, ie:
insert into POTable
select * from Pending
where sessionid = X (or whatever)

delete from Pending where sessionid = X

and if successful - report back to the user.

So brief as to (probably) be useless, but maybe it might help. Feel free to ask more....


--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
Go to Top of Page
   

- Advertisement -