Lost Password?

Go Back   CodeCall Programming Forum > Web Development Forum > ASP, ASP.NET and Coldfusion

Vote on your favorite hash algorithm here!

ASP, ASP.NET and Coldfusion Microsoft's Web Development Language (ASP/ASP.NET) and Coldfusion discussion

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-18-2008, 10:56 AM
ahlaj77 ahlaj77 is offline
Newbie
 
Join Date: Mar 2008
Posts: 1
Credits: 4
Rep Power: 0
ahlaj77 is on a distinguished road
Exclamation Need help sending information from an ASP.NET form to a database

Hello there,
I am in need of trying to figure out what is the best way to send data submitted from a form online to a database. I have a webform that will be submitting user requests, and when the information is submitted I would like it to be inserted into my Request Database. Right now the only things I have on my form are as follows:
User ID [ txtUserID ]
User Email [ txtUserEmailAddress ]
Request [ txtRequestSummary ]

and a submit and cancel button

Would this require me to use any type of stored procedures? This will be an on going website and I would like to set it up where it can be 'easy maintanence' if the database needed fixing/updating etc. I would appreciate your help! Thank you so much

Also the database name is called "Database"
Using MS Server 2003
Using C# as the language in Visual Studio
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 09-19-2008, 05:32 AM
AntiFreez's Avatar   
AntiFreez AntiFreez is offline
Newbie
 
Join Date: Sep 2008
Location: Kempton Park, JHB , South Africa
Posts: 5
Credits: 20
Rep Power: 0
AntiFreez is on a distinguished road
Question Re: Need help sending information from an ASP.NET form to a database

Hi

I Would say using a ms sql stor proc will do the trick you proc would look somthing like this
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go




ALTER PROCEDURE [dbo].[sp_system_Insert_Area_Data]

@Par_system_Area_Seq INT,
@Par_system_Area_ID INT,
@Par_system_Area_Records INT,
@Par_system_Area_Description VARCHAR(50),
@Par_system_Area_Company_ID INT


AS
BEGIN
INSERT INTO [teledb].[dbo].[tbl_system_Area]
(
[teledb].[dbo].[tbl_system_Area].[fld_system_Area_Seq],
[teledb].[dbo].[tbl_system_Area].[fld_system_Area_ID],
[teledb].[dbo].[tbl_system_Area].[fld_System_Area_Records],
[teledb].[dbo].[tbl_system_Area].[fld_System_Area_Description],
[teledb].[dbo].[tbl_system_Area].[fld_System_Area_Company_ID]
)
VALUES
(
@Par_system_Area_Seq,
@Par_system_Area_ID,
@Par_system_Area_Records,
@Par_system_Area_Description,
@Par_system_Area_Company_ID

)
END

And Your asp.net code would look like this

Public Function Insert_Area_Administration_Information(ByVal intArea_Seq As Int64, _
ByVal intArea_ID As Int64, ByVal intArea_Records As Int64, ByVal strArea_Description As String, _
ByVal intArea_Company_ID As Int64)

Using dbConnection As New SqlClient.SqlConnection(GetConnectionString)
Try
'open SQL Connection To DataBase
dbConnection.Open()
Dim dbcommandInsert As SqlClient.SqlCommand
'Connect to Proc
dbcommandInsert = New SqlClient.SqlCommand("sp_system_Insert_Area_Data", dbConnection)
'Insert Command
With dbcommandInsert
'Verify Paramerters
.CommandType = CommandType.StoredProcedure
.Parameters.Add("Par_system_Area_Seq", SqlDbType.Int).Direction = ParameterDirection.Input
.Parameters.Add("Par_system_Area_ID", SqlDbType.Int).Direction = ParameterDirection.Input
.Parameters.Add("Par_system_Area_Records", SqlDbType.Int).Direction = ParameterDirection.Input
.Parameters.Add("Par_system_Area_Description", SqlDbType.VarChar, 50).Direction = ParameterDirection.Input
.Parameters.Add("Par_system_Area_Company_ID", SqlDbType.Int).Direction = ParameterDirection.Input

.Parameters("Par_system_Area_Seq").Value = intArea_Seq
.Parameters("Par_system_Area_ID").Value = intArea_ID
.Parameters("Par_system_Area_Records").Value = intArea_Records
.Parameters("Par_system_Area_Description").Value = strArea_Description
.Parameters("Par_system_Area_Company_ID").Value = intArea_Company_ID

dbcommandInsert.ExecuteNonQuery()

MsgBox("Area Information Has Sucessfully Been Updated", MsgBoxStyle.Information)
End With
'Error Handler
Catch ex As Exception
MsgBox(ex.Message)
Finally
'Closing DB Connection
dbConnection.Close()
End Try
End Using
Return Nothing
End Function

An the you connection String


Public Function GetConnectionString() As String

' '' get the connection string to the Local database
'Return "Data Source=(local);Database=teledb;" _
' & "Integrated Security=SSPI;"


' 'get the connection string to the Remote database
Return "Network Library=DBMSSOCN;" & _
"Data Source=192.168.1.11,1433;" & _
"Initial Catalog=teledb;" & _
"User ID=sa;" & _
"Password=aa"

End Function

Just Pass You Value to Your Function
Hope this will Help!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 09-19-2008, 06:50 AM
orjan's Avatar   
orjan orjan is offline
Programmer
 
Join Date: Sep 2007
Location: Sunne, Värmland, Sweden
Age: 33
Posts: 159
Credits: 187
Rep Power: 6
orjan will become famous soon enoughorjan will become famous soon enough
Default Re: Need help sending information from an ASP.NET form to a database

just a question, why make it so difficult to do just an insert????

why not just do an insert into ... in your asp-script???
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 09-19-2008, 08:30 AM
AntiFreez's Avatar   
AntiFreez AntiFreez is offline
Newbie
 
Join Date: Sep 2008
Location: Kempton Park, JHB , South Africa
Posts: 5
Credits: 20
Rep Power: 0
AntiFreez is on a distinguished road
Question Re: Need help sending information from an ASP.NET form to a database

Hi orjan,

If you worked with stored proc in MS SQL you will know that it's a bit of work
But when u need to do update / change the insert statement in the future on the page how will u alter the insert statement without opening your asp page

Let’s say you do not have the source code of your page how will and can u handle the insert statement. SQL Stored Proc’s is a bit irritating to work with but your page will be more stable. If you create the database with out stored Proc’s, triggers... how will the database administrator handle the database that u will use. Remember when u develop software think in the future how will u be able to solve a problem.

I programmed with a team of professional developers and they thought me something if you want a short cut of doing stuff your project will also have a short cut of stability. If you want to code, then code. Rather be a coder than an interface designer.

Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 09-19-2008, 11:10 AM
orjan's Avatar   
orjan orjan is offline
Programmer
 
Join Date: Sep 2007
Location: Sunne, Värmland, Sweden
Age: 33
Posts: 159
Credits: 187
Rep Power: 6
orjan will become famous soon enoughorjan will become famous soon enough
Default Re: Need help sending information from an ASP.NET form to a database

well, why not open the asp page, simply?

Stored procedures is a great tool for doing some complicated things, but for a just plain insert, I think its so enormous overkill, as you would still need to enter info to your asp page if the db changes.

an administrator would still need to know the documentation, and it is'nt that many operations you could do on this DB anyway without changing the code calling the sp.

creating sp:s would be another thing if you need to enter the info into several tables and do it within an transaction so you know what's entered or not...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Tutorial: Storing Images in MySQL with PHP Jordan PHP Tutorials 13 09-23-2008 06:11 PM
Linking a Form to a SQL Database newguy15 Database & Database Programming 2 12-04-2007 02:13 AM
Linking Windows form to SQL2005 Database newguy15 Visual Basic Programming 0 11-23-2007 06:04 AM
retrieve information from a database moonrise Java Help 2 07-18-2006 09:41 PM


All times are GMT -5. The time now is 03:00 AM.

Contest Stats

Xav ........ 1357.94
MeTh0Dz|Reb0rn ........ 1080.79
WingedPanther ........ 919.18
marwex89 ........ 906.86
morefood2001 ........ 903.18
John ........ 902.37
Brandon W ........ 777.89
chili5 ........ 312.39
Steve.L ........ 264.99
dcs ........ 240.34

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 83%

Ads