Posts by Zu:
Insert Products
Dim catalogApi As New CatalogEntryApi()
Dim productTypeApi As New ProductTypeApi()
Dim inventoryAPI As New InventoryApi()
Dim dr As SqlDataReader
Dim currentUserId As Long = catalogApi.UserId
Dim Currency_USD As Integer = 840
‘ Create and Populate ApplicantDetails
If currentUserId > 0 Then
Dim folderId As Long = 0
Long.TryParse([folder id], folderId)
Dim productTypeId As Long = 0
Long.TryParse([product id], productTypeId)
Dim price As Decimal = 0
Decimal.TryParse(txtprice.text.ToString().Trim(), price)
Dim entryData As EntryData = Nothing
Dim entryType As Ektron.Cms.Common.EkEnumeration.CatalogEntryType = productTypeApi.GetItem(productTypeId).EntryClass
Select Case entryType
Case Ektron.Cms.Common.EkEnumeration.CatalogEntryType.Kit
entryData = New KitData()
entryData.LanguageId = catalogApi.ContentLanguage
Exit Select
Case Ektron.Cms.Common.EkEnumeration.CatalogEntryType.Bundle
entryData = New BundleData()
entryData.LanguageId = catalogApi.ContentLanguage
Exit Select
Case Ektron.Cms.Common.EkEnumeration.CatalogEntryType.SubscriptionProduct
entryData = New SubscriptionProductData()
entryData.LanguageId = catalogApi.ContentLanguage
Exit Select
Case Else
entryData = New ProductData(catalogApi.ContentLanguage)
Exit Select
End Select
entryData.Title =
entryData.TaxClassId =
entryData.Sku =
entryData.GoLive =
entryData.EndDate =
entryData.CurrencyId = Currency_USD
entryData.ProductType = New ProductTypeData()
entryData.ProductType.Id = productTypeId
entryData.Pricing = New PricingData(Currency_USD, price, price)
entryData.FolderId = folderId
entryData.Html = "Other " & txtclassname.text & _
" " & txtDescription.text & " "
Try
catalogApi.Add(entryData)
lblMessage.Text = lblMessage.Text & "
Entry Saved. ID: " & entryData.Id
Dim inventoryData As New InventoryData()
inventoryData.EntryId = entryData.Id
inventoryData.UnitsInStock =
Try
inventoryAPI.SaveInventory(inventoryData)
Dim tax As New Taxonomy()
Dim itemRequest As New TaxonomyContentRequest()
itemRequest.TaxonomyList =
itemRequest.ContentId = entryData.Id
‘Assign productID
Try
tax.AddTaxonomyItem(itemRequest)
Catch ex As Exception
lblMessage.Text = lblMessage.Text & "
An error occured while saving the taxonomy.
" & ex.Message
End Try
Catch ex As Exception
lblMessage.Text = lblMessage.Text & "
An error occured while saving the inventory.
" & ex.Message
End Try
Catch ex As Exception
lblMessage.Text = lblMessage.Text & "
An error occured while saving the entry.
" & ex.Message
End Try
Else
lblMessage.Text = "Not logged in."
End If
Insert into HTML Form
Dim cApi As New Ektron.Cms.ContentAPI() Dim fSubData As New FormSubmittedData() Dim userapi As Ektron.Cms.UserAPI = New Ektron.Cms.UserAPI() Dim fDataItem As FormFieldDataItem() = New FormFieldDataItem(1) {} fDataItem(0) = New FormFieldDataItem() fDataItem(0).FieldName = "EmployerID" fDataItem(0).DataValue = txtid.text fDataItem(1) = New FormFieldDataItem() fDataItem(1).FieldName = "JobTitle" fDataItem(1).DataValue = txtJobTitle.Text fSubData.DataItems = fDataItem fSubData.DateSubmitted = Now.Date() Try cApi.SubmitFormFieldData([form id], fSubData, [...]
for xml explicit
SELECT 1 AS tag, NULL AS parent, user_id AS [li!1!title], name AS [li!1] FROM t_users FOR xml explicit comes out as: <li title="1">user Name 1 </li> <li title="2">user Name 2 </li> <li title="3">user Name 3 </li> etc.
Debugging Classic ASP in VS08
1. Go to Control Panel>Administrative Tools>Computer Management. Add IWAM_ComputerName account to the Debugger Users group. 2. Create a Web Application Project in VS 2005 and add .asp files. 3. Create a virtual directory in IIS for the web application project that you created. 4. On the properties tab of the virtual directory in IIS do [...]
useful SQL queries
Find all users that are in tblUser table but are not in tblTransaction (very useful if there’s a foreign key issue) SELECT USER_ID FROM tblTransaction WHERE USER_ID NOT IN (SELECT ID FROM TBLUSER) Now this one is used when you have a table linking a many to many relationship. This query pulls all currently assigned [...]
Migrating and Encrypting
getOldUsers – read the ds one by one from the old db, where the passwords are not yet encrypted. InsertUserx – writes the users into your new (current) db, with passwords encrypted. Public Function MigrateUser() As Integer Dim dr As DataRow Dim ds As DataSet Dim dt As DataTable Dim userID As Integer ds = [...]
A more recent version of the file has been saved….
OMG. the following message has been popping up more and more often when using FTP via VS08, and the larger the project gets the more “No”s you have to click…. A more recent version of the file [filename] has been saved to the Web server by [username] on [DateTime] Do you want to replace the [...]
Return Inserted Identity from Stored Procedure
Stored Procedure looks like this: ALTER PROCEDURE [dbo].[spInsertSomething] @txtName varchar(255), @txtDisplayName varchar(80), @txtPhone varchar(50) AS BEGIN INSERT INTO tblSomeTable ( txtName , txtDisplayName , txtPhone ) VALUES ( @ txtName , @ txtDisplayName , @ txtPhone ) SELECT NEWID = SCOPE_IDENTITY() END
.NET Repeaters Cheat Sheet (vb)
<asp:Repeater ID=”rpPostTest” runat=”server” OnItemDataBound=”rpPostTest_OnItemDataBound”> <ItemTemplate> <asp:Label ID=”lblQuestion” runat=”server”></asp:Label> <asp:Label ID=”lblQID” visible=”false” runat=”server”></asp:Label> <br /> <asp:RadioButtonList ID=”answer” runat=”server”  > <asp:ListItem   Text=”True”  Value=”T” ></asp:ListItem> <asp:ListItem  Text=”False”  Value=”F”></asp:ListItem> </asp:RadioButtonList> <hr /> </ItemTemplate> </asp:Repeater> create the repeater <asp:Repeater ID="rpPostTest" runat="server" OnItemDataBound="rpPostTest_OnItemDataBound"> <ItemTemplate> <asp:Label ID="lblQuestion" runat="server"></asp:Label> <asp:Label ID="lblQID" visible="false" runat="server"></asp:Label> <br /> <asp:RadioButtonList ID="answer" runat="server" > <asp:ListItem Text="True" [...]
A few useful things to remember…
App_Offline.htm “The way app_offline.htm works is that you place this file in the root of the application. When ASP.NET sees it, it will shut-down the app-domain for the application (and not restart it for requests) and instead send back the contents of the app_offline.htm file in response to all new dynamic requests for the application. [...]