If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > How to add record from ASP.NET to SQL Server

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-26-03, 14:39
MonicaBill MonicaBill is offline
Registered User
 
Join Date: Sep 2003
Location: Dallas
Posts: 5
Unhappy 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)

cmdNewUser.executeNonquery()

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
Reply With Quote
  #2 (permalink)  
Old 12-26-03, 15:34
rnealejr rnealejr is offline
Registered User
 
Join Date: Feb 2002
Posts: 2,232
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 ?
Reply With Quote
  #3 (permalink)  
Old 01-05-04, 23:20
mhaeri mhaeri is offline
Registered User
 
Join Date: Dec 2003
Posts: 5
Smile Add From Asp.net to Sqlserver

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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On