Asp.Net – Adding Parameters to CommandType.Text
This is how you add parameters to a standard CommandType.Text SQL call.
This should prevent sql injection attacks.
Using conSQL = New SqlConnection("CONNECTION STRING TO DATABASE") Try str = "SELECT * FROM TableName where customerid = @CustomerID and CartType = @CartType" cmdSQL = New SqlCommand(str, conSQL) cmdSQL.CommandType = CommandType.Text cmdSQL.Parameters.AddWithValue("@CustomerID", CustomerID) cmdSQL.Parameters.AddWithValue("@CartType", cartType) cartcount = cmdSQL.ExecuteScalar() Catch ex As Exception cartcount = 0 End Try End Using |
Free Webcam Security – Dorgem – WinSCP
This is how you setup a free home security webcam using dorgem and winscp.exe.
First Download:
- Download WinSCP and install it.http://winscp.net/
- Download Dorgem and install it. http://dorgem.sourceforge.net/
Next Configure Dorgem:
Most people are going to want to use the “Web Server” option. This will setup a webserver with your webcam on it…. Pretty straight forward.
But, when I was looking this up, I couldn’t find anywhere that tells you how to use WinSCP. So here I go:
First Configure WinSCP
- Open WinSCP
- New
- Type in all the correct info in session
- Make sure you set a default folder under Environment->Directories->Remote Directory
- Save… and remember the name of the session
- Connect and make sure you set it to remember passwords and everything
Second Configure Dorgem:
- Open Dorgem
- Preview the source
- Click “Store Settings”
- Add
- External Program
- Name it something to remember
- Check Enable
- Command: “C:\Program Files (x86)\WinSCP\winscp.exe” name_of@winscp_session.com /upload %s /defaults
- OK
- Click “Capture Now” to test it out.
- You should now see a tmp file on the WinSCP server.
- If you dont, then you might want to try changing the path to WinSCP in the command or double check the name of the stored WinSCP session in the command.
- Then, you can enable motion detection under “options” on the main screen
Hope this helps some people!
Asp DropDownList – States – ListItem Example
Compiled List of US State Drop Downs for Asp.Net Forms:
Hope this helps!
<asp:DropDownList ID="ddlState" runat="server"> <asp:ListItem Value="" Selected="True">Select a State</asp:ListItem> <asp:ListItem value="AL">Alabama</asp:ListItem> <asp:ListItem value="AK">Alaska</asp:ListItem> <asp:ListItem value="AZ">Arizona</asp:ListItem> <asp:ListItem value="AR">Arkansas</asp:ListItem> <asp:ListItem value="CA">California</asp:ListItem> <asp:ListItem value="CO">Colorado</asp:ListItem> <asp:ListItem value="CT">Connecticut</asp:ListItem> <asp:ListItem value="DC">D.C.</asp:ListItem> <asp:ListItem value="DE">Delaware</asp:ListItem> <asp:ListItem value="FL">Florida</asp:ListItem> <asp:ListItem value="GA">Georgia</asp:ListItem> <asp:ListItem value="HI">Hawaii</asp:ListItem> <asp:ListItem value="ID">Idaho</asp:ListItem> <asp:ListItem value="IL">Illinois</asp:ListItem> <asp:ListItem value="IN">Indiana</asp:ListItem> <asp:ListItem value="IA">Iowa</asp:ListItem> <asp:ListItem value="KS">Kansas</asp:ListItem> <asp:ListItem value="KY">Kentucky</asp:ListItem> <asp:ListItem value="LA">Louisiana</asp:ListItem> <asp:ListItem value="ME">Maine</asp:ListItem> <asp:ListItem value="MD">Maryland</asp:ListItem> <asp:ListItem value="MA">Massachusetts</asp:ListItem> <asp:ListItem value="MI">Michigan</asp:ListItem> <asp:ListItem value="MN">Minnesota</asp:ListItem> <asp:ListItem value="MS">Mississippi</asp:ListItem> <asp:ListItem value="MO">Missouri</asp:ListItem> <asp:ListItem value="MT">Montana</asp:ListItem> <asp:ListItem value="NE">Nebraska</asp:ListItem> <asp:ListItem value="NV">Nevada</asp:ListItem> <asp:ListItem value="NH">New Hampshire</asp:ListItem> <asp:ListItem value="NJ">New Jersey</asp:ListItem> <asp:ListItem value="NM">New Mexico</asp:ListItem> <asp:ListItem value="NY">New York</asp:ListItem> <asp:ListItem value="NC">North Carolina</asp:ListItem> <asp:ListItem value="ND">North Dakota</asp:ListItem> <asp:ListItem value="OH">Ohio</asp:ListItem> <asp:ListItem value="OK">Oklahoma</asp:ListItem> <asp:ListItem value="OR">Oregon</asp:ListItem> <asp:ListItem value="PA">Pennsylvania</asp:ListItem> <asp:ListItem value="RI">Rhode Island</asp:ListItem> <asp:ListItem value="SC">South Carolina</asp:ListItem> <asp:ListItem value="SD">South Dakota</asp:ListItem> <asp:ListItem value="TN">Tennessee</asp:ListItem> <asp:ListItem value="TX">Texas</asp:ListItem> <asp:ListItem value="UT">Utah</asp:ListItem> <asp:ListItem value="VT">Vermont</asp:ListItem> <asp:ListItem value="VA">Virginia</asp:ListItem> <asp:ListItem value="WA">Washington</asp:ListItem> <asp:ListItem value="WV">West Virginia</asp:ListItem> <asp:ListItem value="WI">Wisconsin</asp:ListItem> <asp:ListItem value="WY">Wyoming</asp:ListItem> </asp:DropDownList> |
More State Drop Downs After the fold:
Continue reading “Asp DropDownList – States – ListItem Example”
Asp.Net VB – Listview – ItemCommand – DataKeys – CommandName – SQL
Here is a basic Listview that has an ItemCommand and ItemDataBound:
Frontend Code:
<asp:ListView ID="lvAddresses" runat="server" DataKeyNames="AddressID,BillingAddressID,ShippingAddressID"> <LayoutTemplate> <asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder> </LayoutTemplate> <ItemTemplate> <table class="noborder address_book" cellpadding="0" cellspacing="0"><tbody> <tr> <td colspan="2"> <%#DataBinder.Eval(Container.DataItem, "FirstName")%> <%#DataBinder.Eval(Container.DataItem, "LastName")%><br> <%#DataBinder.Eval(Container.DataItem, "Address1")%><br> <%#DataBinder.Eval(Container.DataItem, "City")%>, <%#DataBinder.Eval(Container.DataItem, "State")%>, <%#DataBinder.Eval(Container.DataItem, "Zip")%><br> <%#DataBinder.Eval(Container.DataItem, "Phone")%><br> <span class="caption"><asp:LinkButton ID="lnkMakeDefault_Billing" CommandName="MakeDefault_Billing" runat="server">Click to make Default Billing Address</asp:LinkButton></span> <span class="caption"><asp:Literal ID="litMakeDefault_Billing" runat="server" Text="Default Billing Address"></asp:Literal></span> <br /> <span class="caption"><asp:LinkButton ID="lnkMakeDefault_Shipping" CommandName="MakeDefault_Shipping" runat="server">Click to make Default Shipping Address</asp:LinkButton></span> <span class="caption"><asp:Literal ID="litMakeDefault_Shipping" runat="server" Text="Default Shipping Address"></asp:Literal></span> </td> </tr> <tr> <td> <asp:Button ID="Button1" runat="server" Text="EDIT" CommandName="EDITAddress"/> </td> <td> <asp:Button ID="btnREMOVE" runat="server" Text="REMOVE" CommandName="REMOVEAddress"/> </td> </tr> </tbody></table> </ItemTemplate> </asp:ListView> |
Backend Code:
Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender FindIt() End Sub Private Sub FindIt() lblAddresses.Text = "" Dim sqlDataConnection As System.Data.SqlClient.SqlConnection = CDataAccess.OpenDatabase Dim conStr As String = sqlDataConnection.ConnectionString sqlDataConnection.Close() Dim selectCommand As String = "SELECT Address.*, Customer.BillingAddressID, Customer.ShippingAddressID" selectCommand &= " FROM Address INNER JOIN Customer ON Address.CustomerID = Customer.CustomerID" selectCommand &= " WHERE Address.CustomerID = @CustomerID AND Address.Deleted = 0" Dim sds As New SqlDataSource() sds.ConnectionString = conStr sds.SelectParameters.Clear() sds.SelectParameters.Add("CustomerID", 12345) sds.SelectCommand = selectCommand lvAddresses.DataSource = sds lvAddresses.DataBind() End Sub Protected Sub lvAddresses_ItemCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ListViewCommandEventArgs) Handles lvAddresses.ItemCommand Dim dataItem As ListViewDataItem = e.Item Dim currentDataKey As DataKey = lvAddresses.DataKeys(dataItem.DataItemIndex) Dim AddressID As Integer = currentDataKey("AddressID") Dim BillingAddressID As Integer = currentDataKey("BillingAddressID") Dim ShippingAddressID As Integer = currentDataKey("ShippingAddressID") 'MakeDefault_Billing 'MakeDefault_Shipping 'EDITAddress 'REMOVEAddress If String.Equals(e.CommandName, "MakeDefault_Billing") Then MakeDefault(AddressID, True) ElseIf String.Equals(e.CommandName, "MakeDefault_Shipping") Then MakeDefault(AddressID, False) ElseIf String.Equals(e.CommandName, "EDITAddress") Then EditAddress(AddressID) ElseIf String.Equals(e.CommandName, "REMOVEAddress") Then RemoveAddress(AddressID) End If End Sub Protected Sub lvAddresses_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ListViewItemEventArgs) Handles lvAddresses.ItemDataBound Dim dataItem As ListViewDataItem = e.Item If e.Item.ItemType = ListViewItemType.DataItem Then Dim currentDataKey As DataKey = lvAddresses.DataKeys(dataItem.DataItemIndex) Dim AddressID As Integer = currentDataKey("AddressID") Dim BillingAddressID As Integer = currentDataKey("BillingAddressID") Dim ShippingAddressID As Integer = currentDataKey("ShippingAddressID") lit = e.Item.FindControl("litMakeDefault_Billing") Dim lit2 As Literal = e.Item.FindControl("litMakeDefault_Shipping") lnk = e.Item.FindControl("lnkMakeDefault_Billing") Dim lnk2 As LinkButton = e.Item.FindControl("lnkMakeDefault_Shipping") lit.Visible = Not lnk.Visible End If End Sub |
Micaela’s Family
ASPDotNetStoreFront: Adding Topic to XML Packages or .aspx Pages
This is how you add a DotNetStoreFront’s Topic into a XMLPackage:
<xsl:value-of select="aspdnsf:Topic('TOPIC_NAME')" disable-output-escaping="yes"/> |
Now, if you want to add it to a .aspx or .ascx page on dnsf:
<aspdnsf:Topic runat="server" ID="Topic1" TopicName="TOPIC_NAME" /> |
Simple PHP Pseudo Proxy
This is the code for a simple php pseudo proxy. If you are blocked by a firewall and google cache isn’t working for some reason. You can use a url with this php file in it:
<?php $filename = $_GET["url"]; if (isset($filename)) { $handle = fopen($filename, "rb"); $contents = stream_get_contents($handle); print $contents; fclose($handle); } else { echo "url"; ?> <form method="GET"> <input type="text" name="url" /><input type="submit"/> </form> <?php } ?> |
Then you can go to where the url is hosted and try something like this:
index.php?url=http%3A%2F%2Fwww.last.fm%2Fuser%2Fdanfolkes%2Fcharts%3Frangetype%3D6month%26subtype%3Dartists |
FoxToPhone – Send Links from Firefox to Android – (Like ChromeToPhone)
Just found out about FoxToPhone.
It gives you a little button in Firefox that allows you to send it to be opened by your browser on your Android phone.
The integration is seamless and it works like a charm.
Useful Links:
- Firefox Plugin: FoxToPhone
- Android App: Google Chrome to Phone
Small After Lunch Motorcycle Ride
This was a fun little motorcycle ride after my lunch break today.
Bon Air, VA
- curves
- hills
- train tracks
- not a ton of traffic
- paved