Jump to content

Yahweh

Members
  • Posts

    186
  • Joined

  • Last visited

Posts 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.

    Hi.. For that retrive data via mysql query and process on it via regular expression /([a-zA-Z]+)([0-9]+)([a-zA-Z]+)/ - match this expression with that column preg_replace('([a-zA-Z]+)([0-9]+)([a-zA-Z]+)','\2','COLUMN_VALUE') with the help of above function use update query to replace with digits only.Regards,Vijay
    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. Hello all,I'd a web form, and this form must enter data to multiple tables lets say now: 2 tables, (Voucher and Customer)CustomerID is a forgein key in Voucher Table, and Voucher Table has a voucherId in it, how can I insert both CustomerID and its information to the Customer Table and also insert the CustomerID to the Voucher table?Thanks in advance
    declare @lastID intINSERT INTO Customer (columns) VALUES (values);set @lastID = scope_identity()INSERT INTO Voucher(CustomerID) VALUES (@lastID);

  4. Hello Experts :) I am having trouble with the Google search engine results showing a page that has been renamed. I may have a flaw in the way I edit my webpages.1. I name my pages index.html2. When I make a change, I do it offline.3. Before I upload the new page, I rename the index.html file on the server to indexv1.html or indexv2.html 4. I then upload a new index.html file.5. When I try a Google search, it shows results that include the old renamed files. (indexv1.html) :) I am only keeping the old renamed files on the server as a backup. I don't want them to be seen by anyone anymore.My Questions: What basic mistakes am I making? Should I be deleting the old files? Am I on the correct section of this forum? :) Thanks you in advance -Skywalker
    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.
  5. HI Everyone,I've built a site using asp and vbscript and what i need to do is have some information automatically submitted to my database upon the user arriving on the desired page.At the moment the information is automatically collected but to submit it into my database im using a form which requires the submit button to be pressed.Any ideas please?
    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

  6. Thanks for your help.I still have the error."Error 4 Could not load type 'ListArticleSortable'. D:\Ufile\www\net\default.aspx 1"Here is the code for default.aspx and default.aspx.vb.default.aspx
    <%@ Page Language="vb" AutoEventWireup="false" 		Codebehind="default.aspx.vb" 		Inherits="ListArticleSortable"%> ...

    default.aspx.vb

    Imports System.CollectionsImports System.IOPublic Class ListArticleSortable	Inherits System.Web.UI.Page	...End Class

    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.
  7. Hi,I try to declare my inherits like this and I get an error.I don't know how to fix. I'm a newbie on .net .Please help!Thx
    <%@ Page Language="vb" AutoEventWireup="false" 		Codebehind="default.aspx.vb" 		Inherits="net.ListArticleSortable"%>

    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:ClassDefault.gifNote 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.
  8. SELECT models.idModel, models.name, Sum(stones.size) AS BTEFROM (models INNER JOIN modelStones ON models.idModel = modelStones.idModel) INNER JOIN stones ON modelStones.idStone = stones.idStoneGROUP BY models.idModel, models.name;

    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;

  9. HiI want to sort an array but it did not work
    <% @Page Language="C#" %><% @Import Namespace="System.IO" %><script language="C#" runat="server">DirectoryInfo di = new DirectoryInfo(@"D:\Ufile\www\code");FileInfo[] rgFiles = di.GetFiles("*");Array.Sort(rgFiles) </script>

    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

  10. <input name="RecievedNotification" type="checkbox" id="RecievedNotification" value = "<%If RecievedNotification = "-1" Then Response.Write("checked=""checked""") : Response.Write("")%>" />Is this correct? If it is why is the check not visible? If not correct please help.
    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("")%>" />

  11. I am creating a content management system using MsSQL and ASP, and I want to make it as secure as I can. So my question is, what characters should I block the user from entering in my database? And a more general question, what are some things I should do in general to keep myself safe from attacks and the like? Thanks in advance!:)EDIT: If it helps I am using ASP (not .NET) with JScript (not VB).
    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.
  12. hi friendsi recently developed a c#.net website with backend as ms sql server 2000. i buyed web space and database from vendor. i have access to my sql database through quey analyszer but it is time consuming and hard to handele ifro new person. i want to know how could i take backup of my database and also perform regular operations on databse such as create,update,delete etc without much details is there any tool available for the same purpose please give me some infromation thank you,
    Download SQL Server Management Studio Express. Its a very good piece of software for being free.
  13. Hello everybody,Assume I have this table called "Messages":MSGID (PK, Auto-Increment) | UID(Int32) | Body(TEXT)------------------------------------------------1 | 20 | Hello what's up user 202 | 21 | Hello what's up user 21In order to insert a single row (or Message):INSERT INTO Messages(UID, Body) VALUES(20, "Have a good morning user 20")This would insert a Message to User 20 with the message body "Have a good morning ... "What if I want to Insert a message (same message) for more users at one single Insert statement? Assuming I have a comma-seperated string containing all the UIDs of the users I want to add a message to? is it even possible?Thanks in advance,homiee
    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)

  14. Hi Guild !I have a table User include field : ID,Username,password . I want make a page Search.aspx.cs for find a user in table User. Please help me code (I'm newbie learning C#). Help me!
    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.

  15. Hello!Finally I never have to go to school anymore but yes, I did search for 3 schools here in Norway but if I don't get to my 1. or 2. choice, I don't want to go to school (1 and 2 has some webdesigning and programming at school) so I have decided I want to move over to USA if I don't get in at 1. or 2. choice but if I get into 1. or 2. I will move after the school is doneBut I don't know where to move. I have been thinking of New York or LA but I've heard both places are expensive...So are there any "cool" places where it's not very expensive? (If there is in NY or LA that'd be nice).Oh yeah, I'm tired of school because 10 years with no break (except some vacations - longest is 2 months) that becomes way too much for me and that's why I have been...well, don't really want to tell you (maybe later)So suggestions anyone?Thanks in advance :)* Maybe not the best place to discuss this, but since many of you live in USA I thought this was the place to ask *
    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.
  16. Why my server cannot run ASP code?
    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?
  17. thanks Yahweh,how would i do it in asp and access and i probably later on put it in sql. Would be great if i knew both.
    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

  18. How can i in a sql statement insert a record then retrieve the id of the record so i could use that id to be assigned to the subject of outlook email - all happens when the users clicks on the submit form button
    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

  19. Yeah, VB is wonderful, isn't it? I get this all the time, I've never done the research to determine what the difference between a "function" and a "sub" is
    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.
  20. 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:

    Validation (ASP.Net): Element 'asp:GridView' is missing required attribute 'runat'.
    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.

  21. 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:asp1ns7.th.gifThat 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:asp2cu8.th.gifThat 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:asp3xs3.th.gif- 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:asp4ll1.th.gif- 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.

  22. 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...