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!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|