Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2003

    Unhappy Unanswered: How to add record from ASP.NET to SQL Server

    Hello engineers
    I hope you all have a good holidays but not me. I am having problem with web form which I want it to post data into SQL server when user click on the button. I don't know what is "Wrong" with my sorry code!!! It bugged me for 4 days now. Can any one please point out what I did wong here: ( the following code is attached to button_click of server button control)

    Dim myConnection As SqlConnection = New _
    SqlConnection("server=(local);database=WebDatabase ;uid=sa;pwd=")

    Dim cmdNewUser As New SqlCommand()
    cmdNewUser.Connection = myConnection
    cmdNewUser.CommandText = "INSERT INTO UserInfo_T " & _
    "(ULastname, Ufirstname, email, Agency, Address, City, State, zip, Phone, LoginName, Password, IsAdministrator) " & _
    "VALUES (@ULastname, @Ufirstname, @email, @Agency, @Address, @City, @State, @zip, @Phone, @LoginName, @Password);"

    cmdNewUser.Parameters.Add("@Ulastname", txtLastName)
    cmdNewUser.Parameters.Add("@firstname", txtFirstName)
    cmdNewUser.Parameters.Add("@email", txtEmail)
    cmdNewUser.Parameters.Add("@Agency", txtAgency)
    cmdNewUser.Parameters.Add("@Address", txtAgencyAddress)
    cmdNewUser.Parameters.Add("@City", txtAgencyCity)
    cmdNewUser.Parameters.Add("@State", txtAgencyState)
    cmdNewUser.Parameters.Add("@Zip", txtAgencyZip)
    cmdNewUser.Parameters.Add("@Phone", txtAgencyPhone)
    cmdNewUser.Parameters.Add("@loginname", txtLoginName)
    cmdNewUser.Parameters.Add("@Password", txtPassword)


    I am using ASP.NET version 1.0XXX. The page I received back said that something ... wrong with connection. Thanks very much in advance for reading my message

  2. #2
    Join Date
    Feb 2002
    Be specific in your server parameter - also, is your sa password really blank ? At what point in your code does the error occur and what is the specific error returned ?

  3. #3
    Join Date
    Dec 2003

    Smile Add From to Sqlserver

    Please examin this statement:
    "Server=(local);database=Webdatabase;trusted_conne ction=true;"
    I hope this Expression Help you.

Posting Permissions

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