CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2003
    Posts
    16

    Email Address Text String Problem

    Hi,

    I am having a problem storing an Email Address in an SQL database using .net (ASP). I think the problem is in .net.

    I run a storred procedure by passing parameters.
    Some code:

    SqlCommand1.Parameters("@Email").Value = Str(htxtEmail.Value)
    SqlCommand1.Parameters("@UserID").Value = CStr(txtUserID.Value)
    SqlCommand1.Parameters("@Password").Value = Password1.Value
    SqlCommand1.Parameters("@FName").Value = FName.Value
    SqlCommand1.Parameters("@LName").Value = LName.Value
    SqlCommand1.Parameters("@Zip").Value = Zip.Value SqlCommand1.Parameters("@CountryCode").Value = RTrim(ddlCountry.SelectedItem.Value)

    SqlCommand1.ExecuteScalar()

    If I enter an Email Address such as [email protected] I get this error: "Input string was not in a correct format." I think .net is interpetting a small Email address as a number somehow.

    I have tried many dtring conversions and changes to Parameter collections but no help.

    The Stack Trace is attached in case somebody knows how to interpet it.

    Anybody have any ideas????
    Attached Files Attached Files

  2. #2
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868
    Try htxtEmail.Text instead of htxtEmail.Value

  3. #3
    Join Date
    Feb 2003
    Posts
    16
    Thanks for the reply.

    I am currently using a html input box (run at server) which has only the "value" property. I have also tried the asp textbox with the "text" property but got the same result as before.

    Any other ideas out there???

  4. #4
    Join Date
    Jan 2000
    Posts
    264
    What datatype are you declaring your parameters as?

    Post your code where you are creating your parameters
    For example:

    Code:
            Dim cmd As SqlClient.SqlCommand
            With cmd.Parameters
                .Add("@Param1", DbType.String)
            End With

  5. #5
    Join Date
    Feb 2003
    Posts
    16
    Hi,

    I am using the Colletion Property in SqlCommand for setting parameter types. My settings are:

    @Email Properties:
    Direction = Input
    Precision = 0
    Scale = 0
    Size = 75
    Source Column = "blank"
    Source Version = Current
    SqlDbType = Char
    Value = "blank"

    I have also tried SqlDbType = VarChar and = Text

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured