|
-
May 17th, 2013, 11:41 AM
#1
Thread Starter
New Member
ASP to VB conversion for a web method
I need the following code converted to VB to work in a web method I am creating. I had tried a few different things with no success. Hoping someone might be able to help me out. Thanks!
strSQL = "SELECT @@IDENTITY AS recid"
Set rsTemp = ocnComp.Execute(strSQL)
If Not rsTemp.EOF Then
strRecid = Trim(rsTemp("recid"))
i = 0
Do While Len(arrParts(i, 0)) > 0
' Create the INSERT statement for the 'detail' table.
strSQL = "INSERT INTO seqexp_detail (recid, custpart, qty, comment, who, active) " & _
"VALUES (" & strRecid & ", '" & arrParts(i, 0) & "', '" & arrParts(i, 1) & "', '" & arrParts(i, 2) & "', '" & arrParts(i, 3) & "', 1)"
'ocnComp.Execute(strSQL)
i = i + 1
Loop
-
May 17th, 2013, 01:08 PM
#2
Re: ASP to VB conversion for a web method
I tried fixing a car. I inserted herrings with no success...
that's about what I got from the post...
"I had tried a few different things with no success." -- what did you try and what does "no success" mean? Did you get errors? Did something not happen when it should have? Did something happen when it shouldn't have?
I will say this... your use of select @@IDENTITY is incorrect... that will return the ID of the LAST THING INSERTED! Any where! Even if in some other table... and you're selecting that BEFOREyou do any thing else. tisk tisk tisk....
If recid is in fact an IDENTITY field... then you shouldn't be inserting it at all... you should jsut let it fill in itself. Also, with the current setup you're inserting the same value for that field...
Then again... you didn't provide any context or indication on what SHOULD be going on...
So all I can suggest is to remove the eels from your hovercraft and try again. For help with removing the eels, there's actually a link in my sig that covers this.
-tg
-
May 17th, 2013, 01:28 PM
#3
Thread Starter
New Member
Re: ASP to VB conversion for a web method
The chunk of code sets a query string, executes it, and then finds the recid and if the end of the results from the SQL execution then it sets strRecid to the the value of the recid. It loops through for the length of arrParts executing that INSERT each time. The part that I'm having the most trouble with is converting the following portion to VB since .EOF is ASP.
Set rsTemp = ocnComp.Execute(strSQL)
If Not rsTemp.EOF Then
strRecid = Trim(rsTemp("recid"))
I tried the following but it says .EOF is not a member of "Integer" but in this case rsTemp has to be an integer.
strSQL = "SELECT @@IDENTITY AS recid"
Dim rsTemp = objRk.genericSqlexec(strSQL, objRk._SQLRl) 'Set rsTemp = ocnComp.Execute(strSQL)
If Not rsTemp.EOF Then
strRecid = Trim(rsTemp("recid"))
I just need to get the value of the recid and set it to strRecid. I don't know what you mean by the @@IDENTITY isn't used correctly, it works fine. I can also see why engineers get a bad wrap of not being people persons. I appreciate the help but you sir come off very rude and degrading.
-
May 18th, 2013, 09:05 AM
#4
Re: ASP to VB conversion for a web method
and now you've introduced a new method: objRk.genericSqlexec(strSQL, objRk._SQLRl) with no mention what it is or what it returns... given that you now have an error that .EOF is not a member of Integer... I'd hazard a guess that it returns an integer and not the recordset you are expecting. Check to see if the value that got returned is the value you're expecting. Specifically see if it is the identity value you're looking for... if it comes back as 1 and not the identity you're expecting.... look at the method call genericSqlExec and see just what it does return...
-tg
Last edited by techgnome; May 18th, 2013 at 09:18 AM.
-
May 20th, 2013, 10:17 AM
#5
Thread Starter
New Member
Re: ASP to VB conversion for a web method
Thank you I got it to work.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|