Click here to Skip to main content
15,926,507 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: How to caputer the formload complete event from parent form Pin
Member 227165514-Mar-06 22:35
Member 227165514-Mar-06 22:35 
GeneralRe: How to caputer the formload complete event from parent form Pin
sathish s14-Mar-06 22:50
sathish s14-Mar-06 22:50 
GeneralRe: How to caputer the formload complete event from parent form Pin
Member 227165514-Mar-06 23:09
Member 227165514-Mar-06 23:09 
QuestionMessage box in VB.NET Pin
rama m14-Mar-06 17:31
rama m14-Mar-06 17:31 
AnswerRe: Message box in VB.NET Pin
Steve Pullan14-Mar-06 17:38
Steve Pullan14-Mar-06 17:38 
AnswerRe: Message box in VB.NET Pin
sathish s14-Mar-06 18:25
sathish s14-Mar-06 18:25 
AnswerRe: Message box in VB.NET Pin
albCode14-Mar-06 22:40
albCode14-Mar-06 22:40 
Questionerror while inserting user to database Pin
uglyeyes14-Mar-06 16:05
uglyeyes14-Mar-06 16:05 
Hi All,

All my field values are stored in array and i am trying to insert a record in a database but i am receiving a error that says:

******
There was an error creating your profile. Please try again later.System.Data.SqlClient.SqlException: The identifier that starts with 'INSERT INTO profiles (CreationDate,ModificationDate,ImageName,ImageCaption,UserName,Password,Email,GenderID,Age,SexualOrientatio' is too long. Maximum length is 128. The name 'INSERT INTO profiles (CreationDate,ModificationDate,ImageName,ImageCaption,UserName,Password,Email,GenderID,Age,SexualOrientatio' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted. The identifier that starts with 'System.InvalidOperationException: The connection is already Open (state=Open). at System.Data.SqlClient.SqlConnection.Open()' is too long. Maximum length is 128. at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at CreateProfileCode.Page_Load()
********
below are my code to add new record
-----------------------------------

'Continue If the User Name has not been used and the e-mail address is neither used nor in the Abusers table.
If (blnUserNameIsUnique AND blnUserIsNotAbuser AND blnEmailNotUsed) Then
blnPrintForm = false
Dim strColumns As New StringBuilder()
Dim strValues As New StringBuilder()
Dim intField As Integer
'Array of all the columns in the Profiles table to be recorded.
Dim ProfileFields(16,1) As String
ProfileFields(0,0) = "UserName"
ProfileFields(0,1) = "text"
ProfileFields(1,0) = "Password"
ProfileFields(1,1) = "password"
ProfileFields(2,0) = "Email"
ProfileFields(2,1) = "text"
ProfileFields(3,0) = "GenderID"
ProfileFields(3,1) = "number"
ProfileFields(4,0) = "Age"
ProfileFields(4,1) = "number"
ProfileFields(5,0) = "SexualOrientationID"
ProfileFields(5,1) = "number"
ProfileFields(6,0) = "EthnicID"
ProfileFields(6,1) = "number"
ProfileFields(7,0) = "Height"
ProfileFields(7,1) = "number"
ProfileFields(8,0) = "BodyTypeID"
ProfileFields(8,1) = "number"
ProfileFields(9,0) = "NeighborhoodID"
ProfileFields(9,1) = "number"
ProfileFields(10,0) = "AboutMe"
ProfileFields(10,1) = "textarea"
ProfileFields(11,0) = "WantActivityPartner"
ProfileFields(11,1) = "checkbox"
ProfileFields(12,0) = "WantFriend"
ProfileFields(12,1) = "checkbox"
ProfileFields(13,0) = "WantDate"
ProfileFields(13,1) = "checkbox"
ProfileFields(14,0) = "WantLTR"
ProfileFields(14,1) = "checkbox"
ProfileFields(15,0) = "ForwardMessages"
ProfileFields(15,1) = "checkbox"
'Astrological Sign added Feb. 14, 2005.
ProfileFields(16,0) = "SignID"
ProfileFields(16,1) = "number"

'Loop through the ProfileFields and build the INSERT statement.
For intField = 0 to 16
Dim strFieldName As String = ProfileFields(intField,0)
Dim strFieldType As String = ProfileFields(intField,1)
Dim strFormValue As String = Request.Form(strFieldName)
If strFormValue <> "" Then
strColumns.Append("," & strFieldName)
Select Case strFieldType
Case "text"
strValues.Append(",'" & strFormValue & "'")
Case "password"
'Use 128-bit encryption.
strValues.Append(",MD5('" & strFormValue & "')")
Case "textarea"
strFormValue = Server.HtmlEncode(strFormValue)
strFormValue = strFormValue.Replace("""","&" & "quot;")
strValues.Append(",""" & strFormValue & """")
Case "number"
strValues.Append("," & strFormValue)
Case "checkbox"
If strFormValue = "on" Then
strValues.Append(",1")
End If
End Select
End If
Next intField

'Create the Activation Code by combining a part of the Session ID and 2 random numbers.
Dim objRandom As New Random()
Dim intStart As Integer = objRandom.Next(1,9)
Dim intLastTwo As Integer = objRandom.Next(10,99)
Dim strCode As String
strCode = Mid(Session.SessionID, intStart, 14) & CStr(intLastTwo)
strColumns.Append(",ActivationCode")
strValues.Append(",""" & strCode & """")

'Create the complete INSERT statement and insert the record.
Dim strInsert As String = "INSERT INTO profiles (CreationDate,ModificationDate,ImageName,ImageCaption" & _
strColumns.ToString() & ") VALUES (NOW(),NOW(),NULL,NULL" & strValues.ToString() & ");"
objCommand.CommandText = strInsert
Try
objCommand.ExecuteNonQuery()

'Send an e-mail to the user with the activation code.
----------------------------

I hope my question makes sense.

please help i tried all night but couldnt figure out why.
AnswerRe: error while inserting user to database Pin
Steve Pullan14-Mar-06 16:49
Steve Pullan14-Mar-06 16:49 
GeneralRe: error while inserting user to database Pin
uglyeyes14-Mar-06 18:15
uglyeyes14-Mar-06 18:15 
GeneralRe: error while inserting user to database Pin
Steve Pullan14-Mar-06 18:49
Steve Pullan14-Mar-06 18:49 
GeneralRe: error while inserting user to database Pin
uglyeyes15-Mar-06 3:04
uglyeyes15-Mar-06 3:04 
GeneralRe: error while inserting user to database Pin
kayos59215-Mar-06 6:57
kayos59215-Mar-06 6:57 
GeneralRe: error while inserting user to database Pin
uglyeyes15-Mar-06 14:29
uglyeyes15-Mar-06 14:29 
GeneralRe: error while inserting user to database Pin
uglyeyes15-Mar-06 15:09
uglyeyes15-Mar-06 15:09 
GeneralRe: error while inserting user to database Pin
kayos59215-Mar-06 15:56
kayos59215-Mar-06 15:56 
GeneralRe: error while inserting user to database Pin
Steve Pullan15-Mar-06 16:00
Steve Pullan15-Mar-06 16:00 
QuestionUpdate modified rows in access database Pin
wiseyuss14-Mar-06 13:23
wiseyuss14-Mar-06 13:23 
AnswerRe: Update modified rows in access database Pin
Chatura Dilan14-Mar-06 14:32
Chatura Dilan14-Mar-06 14:32 
QuestionDrawing Pin
Maurader14-Mar-06 11:52
Maurader14-Mar-06 11:52 
QuestionProducing Summary Reports from a Database Pin
ensuvari14-Mar-06 11:41
ensuvari14-Mar-06 11:41 
AnswerRe: Producing Summary Reports from a Database Pin
noshaba mariam14-Mar-06 23:31
noshaba mariam14-Mar-06 23:31 
GeneralRe: Producing Summary Reports from a Database Pin
ensuvari15-Mar-06 3:25
ensuvari15-Mar-06 3:25 
GeneralRe: Producing Summary Reports from a Database Pin
noshaba mariam15-Mar-06 16:43
noshaba mariam15-Mar-06 16:43 
QuestionChange the DPI Pin
TerryD200014-Mar-06 11:17
TerryD200014-Mar-06 11:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.