Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

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, 15: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, 16: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-06-04, 00: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

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