Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - & Problem
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

& Problem

 Post Reply Post Reply Page  123>
Author
IrishNewbie View Drop Down
Newbie
Newbie


Joined: 06 November 2003
Status: Offline
Points: 38
Post Options Post Options   Thanks (0) Thanks(0)   Quote IrishNewbie Quote  Post ReplyReply Direct Link To This Post Topic: & Problem
    Posted: 06 November 2003 at 9:37am

This is similar to the problem further down the page but im still stumped.

The error is: BC30452: Operator '&' is not defined for types 'String' and 'System.Web.UI.WebControls.TextBox'

my SQL statement is as follows.

aQuery = "Insert Into Students(StudentID, EmailName) VALUES ('"& StudID &"', '"& Email &"')"

Im trying to take the StudID and Email from two textboxes. Is there a couple of lines to take the data from the textboxes and convert it or where am i going wrong??
Appreciate and suggestions.

Thanks

Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 06 November 2003 at 9:39am

('"& StudID &"', '"& Email &"')" i am assuming StudID and Email are text boxes. You have to use

('"& StudID.text &"', '"& Email.text &"')"

Mart.

Back to Top
IrishNewbie View Drop Down
Newbie
Newbie


Joined: 06 November 2003
Status: Offline
Points: 38
Post Options Post Options   Thanks (0) Thanks(0)   Quote IrishNewbie Quote  Post ReplyReply Direct Link To This Post Posted: 06 November 2003 at 9:49am

Thanks very much marty,

Was having awful trouble with what is a simple error! Only started ASP.Net few weeks ago.

 

Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 06 November 2003 at 10:01am
Its alright i know how you feel, i only started a month or so ago...
Back to Top
IrishNewbie View Drop Down
Newbie
Newbie


Joined: 06 November 2003
Status: Offline
Points: 38
Post Options Post Options   Thanks (0) Thanks(0)   Quote IrishNewbie Quote  Post ReplyReply Direct Link To This Post Posted: 06 November 2003 at 10:16am

Marty another question, say i have 5 fields on my form, Student Id, First Name, Last Name, Password, Email.  In my table they are not in that order.  Does that make a difference for taking them in?? I can get it to work for just the StudID and Email but when i try adding the next few i get an error that theres wrong SQL syntax.

 

Bit messy:

Insert Into Students(StudentID, FirstName, LastName, BirthDate, Password, EmailName)

VALUES ('"& StudID.Text &"', '"& F_Name.Text &"', '"& L_Name.Text &"', '"& D_O_B.Text &"', '"& Password1.Text &"', '"& Email.Text &"')"

Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 06 November 2003 at 10:30am

Im not certain what you mean, but if there are StudentID FirstName LastName BirthDate Password and EmailName columns then the SQL you posted will work.

For more info on INSERT INTO http://www.w3schools.com/sql/sql_insert.asp

Mart.

Back to Top
IrishNewbie View Drop Down
Newbie
Newbie


Joined: 06 November 2003
Status: Offline
Points: 38
Post Options Post Options   Thanks (0) Thanks(0)   Quote IrishNewbie Quote  Post ReplyReply Direct Link To This Post Posted: 06 November 2003 at 10:31am

Disregard the last question marty.  Realised it doesnt.

The problem is with the password entry. at the moment i have 2 password fields, password1, password2.  I intend to do a comaprison to ensure they match but at the moment if i only enter data into the first box it gives me an error, when i leave password out of the sql statement it enters the rest perfect. 

Also, sometimes i have to click the create account button twice for the record to go in. the second time i press it, it tells me that theres already a record in there matching.

 

Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 06 November 2003 at 10:37am

You dont need password fields in your db you can just use

If not password1.Text = Password2.Text Then

'if the passwords are wrong

End If

And if you click buttons twice your browser will request the page again thus the insert into query to your database so there will be two lots of the record.

Back to Top
 Post Reply Post Reply Page  123>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.