Public Sub ConvertedVBScriptCode()
Dim moRS As ADODB.Recordset = Nothing
Dim msAction As String
Dim msProductID As String
Dim msProductName As String
Dim msPartNumber As String
Dim msShortDesc As String
Dim msLongDesc As String
Dim msURL As String
Dim msStartDate As String
Dim msExpireDate As String
Dim miContactInfo As String 'WCALHOUN 06/28/04
Dim msTemplateID As String
Dim msBrandIDs As String
Dim msTopicIDs As String
Dim msSolutionIDs As String
' Dim ms
Dim msMsg As String
' Defaults
msAction = "ADD"
msMsg = "<img src=""/images/spacer.gif"" width=""1"" height=""15"" />"
' Check for a POST BACK
If HttpContext.Current.Request.ServerVariables("CONTENT_LENGTH") > 0 Then
Dim lsSQL As String
Dim lsStartDate As String
Dim lsExpireDate As String
msAction = HttpContext.Current.Request.Form("hdnAction")
msProductID = HttpContext.Current.Request.Form("lstIDs")
msProductName = Trim(HttpContext.Current.Request.Form("txtProductName"))
msPartNumber = Trim(HttpContext.Current.Request.Form("txtPartNumber"))
msShortDesc = Trim(HttpContext.Current.Request.Form("txtShortDescription"))
msLongDesc = Trim(HttpContext.Current.Request.Form("txtLongDescription"))
msURL = Trim(HttpContext.Current.Request.Form("txtURL"))
msStartDate = Trim(HttpContext.Current.Request.Form("txtStartDate"))
msExpireDate = Trim(HttpContext.Current.Request.Form("txtExpireDate"))
miContactInfo = Integer.Parse(HttpContext.Current.Request.Form("chxContactInfo")) 'determine if we need to hide contact info
msTemplateID = HttpContext.Current.Request.Form("lstTemplateID")
msBrandIDs = HttpContext.Current.Request.Form("lstBrandIDs")
msTopicIDs = HttpContext.Current.Request.Form("lstTopicIDs")
msSolutionIDs = HttpContext.Current.Request.Form("lstSolutionIDs")
msMsg = "An error occurred during the update."
If msTemplateID.Length = 0 Then
msTemplateID = "null"
End If
If msStartDate.Length = 0 Then
lsStartDate = "null"
Else
lsStartDate = "'" & DB_StringFix(msStartDate) & "'"
End If
If msExpireDate.Length = 0 Then
lsExpireDate = "null"
Else
lsExpireDate = "'" & DB_StringFix(msExpireDate) & "'"
End If
' Update
Select Case msAction.ToUpper
Case "ADD"
lsSQL = "usp_Product_Insert " & _
"'" & DB_StringFix(msProductName) & "'," & _
"'" & DB_StringFix(msPartNumber) & "'," & _
"'" & DB_StringFix(msShortDesc) & "'," & _
"'" & DB_StringFix(msLongDesc) & "'," & _
"'" & DB_StringFix(msURL) & "'," & _
lsStartDate & "," & _
lsExpireDate & "," & _
miContactInfo & "," & _
msTemplateID & "," & _
"'" & msBrandIDs & "'," & _
"'" & msTopicIDs & "'," & _
"'" & msSolutionIDs & "'," & _
"'" & HttpContext.Current.Session("ILS_UserName") & "'"
If DB_Execute(lsSQL) = 0 Then
msMsg = "Product added successfully."
End If
Case "EDIT"
DB_GetRs("usp_Product_GetByPK_List '" & msProductID & "'", moRS)
msMsg = "<img src=""/images/spacer.gif"" width=""1"" height=""15"" />"
msAction = "UPDATE"
Case "DELETE"
lsSQL = "usp_Product_DeleteByPK " & _
"'" & msProductID & "'," & _
"'" & HttpContext.Current.Session("ILS_UserName") & "'"
If DB_Execute(lsSQL) = 0 Then
msMsg = "Product deleted successfully."
End If
Case "UPDATE"
lsSQL = "usp_Product_UpdateByPK " & _
"'" & msProductID & "'," & _
"'" & DB_StringFix(msProductName) & "'," & _
"'" & DB_StringFix(msPartNumber) & "'," & _
"'" & DB_StringFix(msShortDesc) & "'," & _
"'" & DB_StringFix(msLongDesc) & "'," & _
"'" & DB_StringFix(msURL) & "'," & _
lsStartDate & "," & _
lsExpireDate & "," & _
miContactInfo & "," & _
msTemplateID & "," & _
"'" & msBrandIDs & "'," & _
"'" & msTopicIDs & "'," & _
"'" & msSolutionIDs & "'," & _
"'" & HttpContext.Current.Session("ILS_UserName") & "'"
If DB_Execute(lsSQL) = 0 Then
msMsg = "Product updated successfully."
DB_GetRs("usp_Product_GetByPK_List '" & msProductID & "'", moRS)
End If
Case Else
msMsg = ""
End Select
End If
End Sub
You need to add a reference to the ADODB :NET component, and you probably need some tweaks to the above code, such as keping the dates as DateTime variables and not strings etc. The code will compile, although only you can tell us if it works as is. Let me
know how you get on, and we'll take it from there.
Thanks
Carsten
Please click Mark as Answer if this post is of help to you. :-)
You need to add a reference to your project, by using the Add Reference dialog box. Right-click the Web site or Web application in Solution Explorer, and then click
Add Reference. The are various ways of doing this, but in the Add Reference dialog box, click the COM tab, and locate and select the
Microsoft ActiveX Data Objects x.x Library, and then click OK. If you have multiple versions of the
Microsoft ActiveX Data Objects x.x Library listed, select the newest one (the one with the highest version number x.x).
Thanks
Carsten
Please click Mark as Answer if this post is of help to you. :-)
sweety85
Member
1 Points
5 Posts
converting vbscript to vb.net
Jul 26, 2010 01:46 PM|LINK
Hello All,
Can anyone pls help me to convert below vbscript to vb.net
integrasol
Star
12155 Points
2355 Posts
Re: converting vbscript to vb.net
Jul 26, 2010 02:57 PM|LINK
This should get you started:
Public Sub ConvertedVBScriptCode() Dim moRS As ADODB.Recordset = Nothing Dim msAction As String Dim msProductID As String Dim msProductName As String Dim msPartNumber As String Dim msShortDesc As String Dim msLongDesc As String Dim msURL As String Dim msStartDate As String Dim msExpireDate As String Dim miContactInfo As String 'WCALHOUN 06/28/04 Dim msTemplateID As String Dim msBrandIDs As String Dim msTopicIDs As String Dim msSolutionIDs As String ' Dim ms Dim msMsg As String ' Defaults msAction = "ADD" msMsg = "<img src=""/images/spacer.gif"" width=""1"" height=""15"" />" ' Check for a POST BACK If HttpContext.Current.Request.ServerVariables("CONTENT_LENGTH") > 0 Then Dim lsSQL As String Dim lsStartDate As String Dim lsExpireDate As String msAction = HttpContext.Current.Request.Form("hdnAction") msProductID = HttpContext.Current.Request.Form("lstIDs") msProductName = Trim(HttpContext.Current.Request.Form("txtProductName")) msPartNumber = Trim(HttpContext.Current.Request.Form("txtPartNumber")) msShortDesc = Trim(HttpContext.Current.Request.Form("txtShortDescription")) msLongDesc = Trim(HttpContext.Current.Request.Form("txtLongDescription")) msURL = Trim(HttpContext.Current.Request.Form("txtURL")) msStartDate = Trim(HttpContext.Current.Request.Form("txtStartDate")) msExpireDate = Trim(HttpContext.Current.Request.Form("txtExpireDate")) miContactInfo = Integer.Parse(HttpContext.Current.Request.Form("chxContactInfo")) 'determine if we need to hide contact info msTemplateID = HttpContext.Current.Request.Form("lstTemplateID") msBrandIDs = HttpContext.Current.Request.Form("lstBrandIDs") msTopicIDs = HttpContext.Current.Request.Form("lstTopicIDs") msSolutionIDs = HttpContext.Current.Request.Form("lstSolutionIDs") msMsg = "An error occurred during the update." If msTemplateID.Length = 0 Then msTemplateID = "null" End If If msStartDate.Length = 0 Then lsStartDate = "null" Else lsStartDate = "'" & DB_StringFix(msStartDate) & "'" End If If msExpireDate.Length = 0 Then lsExpireDate = "null" Else lsExpireDate = "'" & DB_StringFix(msExpireDate) & "'" End If ' Update Select Case msAction.ToUpper Case "ADD" lsSQL = "usp_Product_Insert " & _ "'" & DB_StringFix(msProductName) & "'," & _ "'" & DB_StringFix(msPartNumber) & "'," & _ "'" & DB_StringFix(msShortDesc) & "'," & _ "'" & DB_StringFix(msLongDesc) & "'," & _ "'" & DB_StringFix(msURL) & "'," & _ lsStartDate & "," & _ lsExpireDate & "," & _ miContactInfo & "," & _ msTemplateID & "," & _ "'" & msBrandIDs & "'," & _ "'" & msTopicIDs & "'," & _ "'" & msSolutionIDs & "'," & _ "'" & HttpContext.Current.Session("ILS_UserName") & "'" If DB_Execute(lsSQL) = 0 Then msMsg = "Product added successfully." End If Case "EDIT" DB_GetRs("usp_Product_GetByPK_List '" & msProductID & "'", moRS) msMsg = "<img src=""/images/spacer.gif"" width=""1"" height=""15"" />" msAction = "UPDATE" Case "DELETE" lsSQL = "usp_Product_DeleteByPK " & _ "'" & msProductID & "'," & _ "'" & HttpContext.Current.Session("ILS_UserName") & "'" If DB_Execute(lsSQL) = 0 Then msMsg = "Product deleted successfully." End If Case "UPDATE" lsSQL = "usp_Product_UpdateByPK " & _ "'" & msProductID & "'," & _ "'" & DB_StringFix(msProductName) & "'," & _ "'" & DB_StringFix(msPartNumber) & "'," & _ "'" & DB_StringFix(msShortDesc) & "'," & _ "'" & DB_StringFix(msLongDesc) & "'," & _ "'" & DB_StringFix(msURL) & "'," & _ lsStartDate & "," & _ lsExpireDate & "," & _ miContactInfo & "," & _ msTemplateID & "," & _ "'" & msBrandIDs & "'," & _ "'" & msTopicIDs & "'," & _ "'" & msSolutionIDs & "'," & _ "'" & HttpContext.Current.Session("ILS_UserName") & "'" If DB_Execute(lsSQL) = 0 Then msMsg = "Product updated successfully." DB_GetRs("usp_Product_GetByPK_List '" & msProductID & "'", moRS) End If Case Else msMsg = "" End Select End If End SubYou need to add a reference to the ADODB :NET component, and you probably need some tweaks to the above code, such as keping the dates as DateTime variables and not strings etc. The code will compile, although only you can tell us if it works as is. Let me know how you get on, and we'll take it from there.
Carsten
Please click Mark as Answer if this post is of help to you. :-)
My Blog
ketan_al
Contributor
6850 Points
1143 Posts
Re: converting vbscript to vb.net
Jul 26, 2010 02:59 PM|LINK
Hi,
Please refer following
http://forums.asp.net/p/986119/1271280.aspx
hope this helps
MCP, MCTS ( ASP.NET 3.5 )
Please mark as answer if it helps :)
sweety85
Member
1 Points
5 Posts
Re: converting vbscript to vb.net
Jul 27, 2010 02:12 PM|LINK
Thank you very much integrasol for the quick reply, I am gettin gthe following erroe when I am trying to run the cod
Compiler Error Message: BC30002: Type 'ADODB.Recordset' is not defined. Do you know what could it be.
Thanks for your help
integrasol
Star
12155 Points
2355 Posts
Re: converting vbscript to vb.net
Jul 27, 2010 02:23 PM|LINK
You need to add a reference to your project, by using the Add Reference dialog box. Right-click the Web site or Web application in Solution Explorer, and then click Add Reference. The are various ways of doing this, but in the Add Reference dialog box, click the COM tab, and locate and select the Microsoft ActiveX Data Objects x.x Library, and then click OK. If you have multiple versions of the Microsoft ActiveX Data Objects x.x Library listed, select the newest one (the one with the highest version number x.x).
Carsten
Please click Mark as Answer if this post is of help to you. :-)
My Blog
sweety85
Member
1 Points
5 Posts
Re: converting vbscript to vb.net
Jul 28, 2010 09:21 PM|LINK
Thanks for the reply, Thaat was very helpful
integrasol
Star
12155 Points
2355 Posts
Re: converting vbscript to vb.net
Jul 29, 2010 05:48 AM|LINK
You're most welcome, but you really need to start a new thread for this new question. :-)
Carsten
Please click Mark as Answer if this post is of help to you. :-)
My Blog
CuongTran030...
Member
2 Points
1 Post
Re: converting vbscript to vb.net
Nov 13, 2012 03:20 PM|LINK
integrasol help me, plz
i write in vb.Net (visual basic 2008), in module, Console but your error code "not declared" ( Httpcontext, DB_StringFix and more )
i added Microsoft ActiveX Data Objects 2.8 Library to my project
plz help me
send to u my capture