Jump to content

Yahweh

Members
  • Posts

    186
  • Joined

  • Last visited

Everything posted by Yahweh

  1. To improve the signal to noise ratio on this forum, here is a brief list of things to delete on sight:- Any threads with the phrases "help me" or "please help me" in the title- Any thread titles that can be matched with the regex "help(!{2,})"- Any posts that says "I have an error in my code, [insert ambiguous error message], how do I fix it?" without corresponding sourcecode.- More than 10 lines of sourcecode that does not appear in the CODE tag || more the 3 lines of PHP outside of code tags.- Any post asking for replies by email rather than in the forum.- Any post asking for something absurd like "please give me the full source of MP3.com".- All posts in the VBScript forum. Clientside VBScript is dead.Addendum:If you choose to improve the signal to noise ratio as I've suggested above, also be sure to delete the "hey! why was my post deleted" posts.
  2. You're out of luck, Suganya, there's no function (at least not an elegant function) to remove alpha characters. You should probably do it programmatically. That expression is too complicated, and it doesn't match strings like "hello324234". You don't need to capture anything, just remove the unwanted characters:preg_replace('[^\d]', '', COLUMN_VALUE)
  3. declare @lastID intINSERT INTO Customer (columns) VALUES (values);set @lastID = scope_identity()INSERT INTO Voucher(CustomerID) VALUES (@lastID);
  4. Yes. You have a bug in your code. Post your code so people can debug it.
  5. You're not expecting your page changes to be reflected on Google instantaneously do you? Depending on the popularity of your site, Google can reindex your site in a couple of days, or it might take a couple of weeks.And if you don't want anyone to see your backup pages, then delete them.
  6. Yahweh

    Automatic insert

    It would be nice to see the code on the page you're trying to submit. I can't think of any reason why the submit button would need to be pressed, unless you're assigning your variables like this:someVar = Request.Form("something") You aren't required to use Request.Form, you can use this instead: someVar = Request("something") So, when a user visits your page, you can put something like this at the top: dim user, monkey, IPAddress, sql'Initializing and escaping variablesuser = Replace(request("user"), "'", "'')monkey = Replace(request("monkey"), "'", "'')IPAddress = Replace(Request.ServerVariables("REMOTE_ADDR"), "'", "'')'Putting them into an SQL statementsql = "INSERT INTO table (user, monkey, IP) values ('[user]', '[monkey]', '[ipAddress]')"sql = replace(sql, "[user]", user, 1, -1, vbTextCompare)sql = replace(sql, "[monkey]", monkey, 1, -1, vbTextCompare)sql = replace(sql, "[IPAddress]", IPAddress, 1, -1, vbTextCompare)'Executing statementConn.Open someDSNConn.Execute(sql)Conn.Close
  7. That code works perfectly fine in .Net 2.0+. It won't work in 1.1. Upgrade to the latest .Net framework and change your website's configuration through IIS to use .Net 2.0.
  8. You don't have a class called "net.ListArticleSortable" in your codebehind, so you can't inherit from it. You can only inherit from the class defined on your codebehind:Note that the class on the codebehind inherits from System.Web.UI.Page. If you don't have that, then ASP.Net doesn't have any of the requisite information it needs to build the page, so you'll get errors.
  9. An inner join combines the rows of one table with all of the rows of another table. So if you have more than one row on your stones table, then you're going to return duplicate entries on your models table.A left join returns only non-null rows in the table to the left of the join operator, which means you only get one row returned per model in your models table. You obviously should use a left join instead:SELECT models.idModel, models.name, Sum(stones.size) AS BTEFROM modelsLEFT JOIN modelStones ON (models.idModel = modelStones.idModel)LEFT JOIN stones ON modelStones.idStone = stones.idStoneGROUP BY models.idModel, models.name;
  10. Yahweh

    sort array C#

    The FileInfo class doesn't implement the IComparable interface, so you can't use the Array.Sort method directly on it. You have to create your own class and implement the IComparer interface (<--- you won't implement the IComparable interface because FileInfo isn't inheritable).Create a class called SortFileInfo:Imports System.IOPublic Class SortFileInfo Implements IComparer Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements System.Collections.IComparer.Compare Dim file1, file2 As FileInfo file1 = CType(x, FileInfo) file2 = CType(y, FileInfo) 'change the .Name attribute if you want to sort by any other property Return String.Compare(file1.Name, file2.Name) End FunctionEnd Class Now you can sort your array based on name: Dim di As New DirectoryInfo("C:\") Dim rgFiles As FileInfo() rgFiles = di.GetFiles("*") Array.Sort(rgFiles, New SortFileInfo) For Each file As FileInfo In rgFiles TextBox1.AppendText(file.Name) TextBox1.AppendText(vbNewLine) Next
  11. Its not correct, it produces invalid HTML. The resulting HTML will look like this:<input name="RecievedNotification" type="checkbox" id="RecievedNotification" value = "" />or<input name="RecievedNotification" type="checkbox" id="RecievedNotification" value = "checked="checked"" /> That's obviously not right because value and checked are two distinct attributes.You want this instead: <input name="RecievedNotification" type="checkbox" id="RecievedNotification" value="y" <%If RecievedNotification = "-1" Then Response.Write("checked=""checked""") : Response.Write("")%>" />
  12. Yahweh

    Security Questions

    If your creating stored procedures, then you only need to fill your command object with the correct parameters and SQL Server will take care of the rest.Otherwise, if you're creating dynamic queries or your queries are embedded in JScript, then escape single quotes (') and double quotes ("). If you're using another database like MySQL, then you should escape backslashes (\) too.
  13. Download SQL Server Management Studio Express. Its a very good piece of software for being free.
  14. Use INSERT...SELECT syntax. Assuming you have a Messages table and a Users table.INSERT INTO Messages(UID, Body)SELECT UID, 'Have a Good morning, user' + UID From Users where UID IN (@list_of_users)
  15. Yahweh

    Search.asp.cs in C#

    Its not too terribly complicated. The only significant part of the search is your SQL query. The way you design your query depends on whether your table has a fulltext index. I'll presume it doesn't for simpliicity.If you're using SQL server, then create a stored procedure like this:Create procedure Find_Users(@username varchar(50))AsSelect * from users where username = @username/*If you want to match partial names, then use this instead:Select * from users where username like '%' + @username + '%'*/ I assume your want your records displayed in a gridview, with a search textbox and search button at the top. The basic markup for Search.aspx will contain a textbox, a search button, a gridview, and an SQL datasource. The textbox will be bound to one of the select parameters of your SQL datasource. The final product will look something like this: <asp:TextBox ID="txtSearch" runat="server"></asp:TextBox> <asp:Button ID="btnSearch" runat="server" Text="Search" /><br /> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="sqlSearch"> <Columns> <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="ID" /> <asp:BoundField DataField="username" HeaderText="username" SortExpression="username" /> </Columns> </asp:GridView> <asp:SqlDataSource ID="sqlSearch" runat="server" ConnectionString="<%$ ConnectionStrings:ASPNetConnectionString %>" SelectCommand="Find_Users" SelectCommandType="StoredProcedure"> <SelectParameters> <asp:ControlParameter ControlID="txtSearch" Name="username" PropertyName="Text" /> </SelectParameters> </asp:SqlDataSource> You don't need any code in your code behind, because txtSearch is bound to one of your select parameters. When you click search, the page will automatically display all of the records that match the user you're searching for.
  16. Based on my own experience:- Mobile, Alabama: a socially regressive hellhole, avoid this place like the plague.- Pensacola, Florida: a nice, respectable place to live, although it has hurricanes.- Navarre, Florida: its been a long time since I lived in Navarre, but it was very quiet, slightly underdeveloped. It compete with Bellevue, NE in terms of having nothing to do, although Fort Walton Beach is close by.- Bellevue, NE: a lower-middleclass suburb, relatively safe compared to NY and LA. There's nothing to do in Nebraska, but its an inexplicably strong Silicon Valley powerhouse. There aren't as many cornfields as you think, although you're always within walking distance of one. Lots of small local businesses and strip malls.- Papillion, NE: an upper-middleclass suburb, and a physically cleaner part of Nebraska. I like Papillion more than Bellevue.- New Orleans, Louisiana: a place to go if you want to have a new crazy story to tell everynight. Its fun, but I didn't like it much. Unless I was just in the wrong part of town and talked to the wrong people, New Orleans has a lot of crime, the culture promotes a kind of perpetual immaturity and anti-intellectualism, and you wouldn't trust your kids with 90% of the people there.- Boulder, Colorado: snow and hippies. WTF?I'd settle for a place in Florida, its a nice place to live.
  17. Why not a more helpful error message? Why not some information that would actually help a person diagnose your problem, such as saynig what server your running, and a sample of the code you're trying to execute?
  18. Imagine I had a table called "articles" with the following setup:- ID (primary key, autoincrement)- Title- Article- DateFirst, make sure you have these ADO constants included on your page. So, in ASP, it looks like this:Dim conn, rs, sql, LastPostIDSet conn = Server.CreateObject("ADODB.Connection")Set rs = Server.CreateObject("ADODB.Recordset")sql = "Select ID, Title, Article, Date from Articles where 1 = 0"RS.CursorLocation = adUseClient '<-- that line of code retains the value of the inserted IDRS.open sql, conn, 1, 3 RS.AddNew RS("Title") = Title RS("Article") = Article RS("Date") = Now RS.Update LastPostID = RS("ID") '<-- this line of code retrieves the IDRS.close
  19. It depends on what database and technology you're using.If you're using ASP.Net and SQL Server, then you can create a stored procedure like this:CREAT PROCEDURE your_stored_procedure(...,@return_value output)ASINSERT INTO some_table (somecols...) VALUES (somevalues...);@return_value = scope_identity() Then, in your code behind, you can access the variable like this: Protected Sub SqlDataSource1_Inserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs) Handles SqlDataSource1.Inserted dim returnValue as integer = cint(e.Command.Parameters.Item("@return_value").ToString) End Sub
  20. A function returns a value, a sub (or sub procedure) doesn't. A sub is equivalent to a void function in any other language.I don't know why it throws a fit about putting parentheses around subs, that's just one of a number of ASP gotchas that worked itself into the language.
  21. Google is your friend.
  22. Yahweh

    Creating a forum

    The next step is creating a page for displaying threads for your forum. I'll leave it up to you to figure out the threads page.Believe me, 2 months is plenty of time to learn ASP.net. You can learn everything you need to learn to make a forum in about 2 weeks. After you learn ASP.Net, it shouldn't take more than 2 or 3 days to put together a working forum.Oh, and if you have an error on your page, for the love the mother goddess, don't say "I have an error! Please help me!".Visual Web Developer is very good at helping you solve errors: there will usually be an "errors" box. When you doubleclick an error, it will take you to the line of code with an error, and it will usually have a descriptive error message. A typical error message is: That means my Gridview control is missing its "runat" attribute. When I doubleclick on the error, it takes me to the following line of code:<asp:GridView ID="GridView1" AutoGenerateColumns="False" DataSourceID="sqlForum" ShowHeader="False" Width="95%" HorizontalAlign="Center"> I can fix that line of code by adding the "runat" attribute: <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="sqlForum" ShowHeader="False" Width="95%" HorizontalAlign="Center"> And the error goes away.You should try to solve errors on your own before you ask for help.If you're genuinely stumped, then do the following:- Copy and paste the error into a new post.- Copy the source code that is causing the error. DO NOT copy/paste the entire page unless you absolutely have to.
  23. Yahweh

    Creating a forum

    I'm not trying to be rude, but when your opening post reads "I need the codes for creating a forum..", that sounds like you're asking other people to do your homework for you. I don't have a problem helping people out, but I won't ever do their homework for them. (I remember once someone on this forum asked "Could someone give me the full ASP code to make MP3.com", and my jaw dropped at such an inane question.)As for setting up an e-commerce website, this online tutorial has an entire chapter dedicated e-commerce development.Now, I'll assume that you have no idea where to start when it comes to making an ASP.net forum. So, to start, do the following:- Download Visual Web Developer from Microsoft. VWD is a lite version of Visual Studio, its a kind of WYSIWYG editor. Normally, I would tell anyone developing websites to use a text editor, but unfortunately ASP.Net is really hard to write in a text editor without the Intellisense built into VWD.- Start Visual Web Developer and create new project -- try to name the project something other than "Website1", and don't use any of the personal starter kits. Make sure the box that says "Place Code In Seperate File" is selected. That box allows you to write whats called a "code behind", which seperates any scripting code from HTML.- The first page you'll get will look something like this:That the Visual Web Developer Interface. The red circle lets you edit your website with the WYSIWYG editor, the blue circle lets you edit the source code.If you know HTML, then most the source code should look familiar to you. You might notice the line at the top of the page is unfamiliar: <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> That's a special ASP.Net directive, that tells the ASP.Net compiler. You don't have to worry about what any of those attributes mean.If you rightclick on either the Design or Source views and click "View Code", you get to a special window that looks like this:That window lets you edit the actual VB.net or C# code on your page.And now, just to get you started at light speed, here is a brief introduction to databases, the Gridview, and databinding:- Open MS Access and create a new a Access database. Make sure the database (it doesn't matter where the database is saved at.)- Create a new table with the following fields:-- ID (autoincrement)-- Title (varchar 50)-- Description (text / Memo)-- ForumOrder (integer / Numeric). This field will be used for controlling what order forums appear on the front page.- Save the table as "Forums" and add a few records to the database.(Note: I uninstalled MS Office a long time ago, so I don't use Access. I use SQL server. Most of the code will be identical to what you could use.)When you have your database set up, go back to Visual Web Developer, and click on your Solution Explorer. Right click the top-most item in the tree, and in the popup menu click "Add ASP.Net Folder", then select "App_Data". That's a special folder for holding data files like databases, XML, spreadsheets, etc. When the App_Data folder is created, right-click on it and choose "Add Existing File", then find the Access database you created and add it.Now you're read to start doing something constructive:- Go to design view and drag a gridview control onto the page (the gridview control is found under the "Data" tab). When you do that, a little window will pop up to the side asking you to chose a datasource. It should look something like this:- Click "New Connection". A window will pop up asking you what kind of datasource to use. Choose "Access Datasource", and you should be able to find your database in the App_Code directory.- Continue through the wizard until you come across a window like this:- You never ever want to specify columns to choose. Almost always, when you get to this point, you'll click the "Specify custom SQL statement or stored procedure" option button. Click that button, then hit next. You'll taken to a window where you can enter your own SQL statement. In that box, copy/paste the following statement: Select ID, Title, Description From Forums ORDER BY ForumOrder - Click next. You can test your query if you want; odds are, if you've done everything I've said correctly, then your query should work fine. Click finish.- You'll notice after you click finish that your Gridview changed its appearance somewhat. That's because the Gridview is set up to automatically generate columns and column data... unless you specify a different default template, which you'll almost always do from this point foward.Now, you just want to change the appearance of your gridview. I like to work with my gridview's appearance in Source code view, so switch to source view, and you'll notice that VWD has added some code to your page. It will look something like this: <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="sqlForum"> <Columns> <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="ID" /> <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" /> <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" /> </Columns> </asp:GridView> I've deleted the BoundField columns, and I've replaced them with a single TemplateField column for more control. My Gridview now looks like this: <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="sqlForum" ShowHeader="False" Width="95%" HorizontalAlign="Center"> <Columns> <asp:TemplateField> <ItemTemplate> <asp:Panel runat="server" ID="pnlTitle" style="background : #FF0099; border : solid 1px #FF99FF; vertical-align : middle;"> <asp:HyperLink style="color : #FFFFFF; font-family : verdana; font-size : 12pt; font-weight : bold; margin : 20px 20px 20px 20px; margin-left : 10px;" runat="server" Text='<%# Eval("Title") %>' NavigateUrl='<%# String.Format("forum.aspx?f={0}", Eval("ID")) %>' /> </asp:Panel> <asp:Panel runat="server" ID="pnlDescription" style="background : #EEEEEE; color : #FF0099;"> <asp:Label runat="server" Text='<%# Eval("Description") %>' style="margin : 4px 4px 4px 4px; margin-left : 20px; margin-bottom : 0px;" /> </asp:Panel> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> Your front page is basically done at this point. Press the F5 key to run your project and see how it looks in your browser. A message box will pop up asking you if you want to edit your web.config file for debugging, click yes. IE should pop up and you should see your finished product.
  24. Wizards are the devil. Just ask any HR person who makes a living shredding resumes made with MS Word's "resume wizard", or ask any web designer who can spot and chuckle at web pages made in Dreamweaver's "personal website" wizard from a mile away.I can think of two solutions to your problem:1) If you writing code in classic ASP or using any Visual Studio earlier than 2005, then create your own database from scratch. You'll have a lot more control and be more intimately familiar with the structure of your tables when you go that route.2) If you're using Visual Studio 2005 or Visual Web Developer, then I presume you're writing code in ASP.net, and your using Visual Studio's built-in membership feature. In that case, take a look at the MSDN documentation on custom profile providers. You can add a new field to a profile by going into your web.config and adding a new property under your profile configuration section: <profile> <properties> <add name="domainname" type="String" /> </properties></profile> When you recompile your project, .Net will add that field into your database automatically.
×
×
  • Create New...