Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
umapathy
Starting Member
24 Posts |
Posted - 2007-03-24 : 02:45:51
|
Hai Alli want to insert records from asp.net page to Sqlserver.i need to use stored procedure.for example table name emp(name,age)how i pass this value to sqlGive me codeRegardsUmapathyUmapathy |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-03-25 : 07:53:58
|
what did you try so far?_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
|
|
sumyy
Starting Member
1 Post |
Posted - 2007-03-26 : 04:56:30
|
Hi,Try this sample code. Public Sub InsertCustomer() Dim connection As SqlConnection = _ New SqlConnection(connectionString) connection.Open() Try Dim command As SqlCommand = _ New SqlCommand("InsertCustomer", connection) command.CommandType = CommandType.StoredProcedure command.Parameters.Add("@CustomerID", "PAULK") command.Parameters.Add("@CompanyName", "Pauly's Bar") command.Parameters.Add("@ContactName", "Paul Kimmel") command.Parameters.Add("@ContactTitle", "The Fat Man") command.Parameters.Add("@Address", "31025 La Jolla") command.Parameters.Add("@City", "Inglewood") command.Parameters.Add("@Region", "CA") command.Parameters.Add("@Country", "USA") command.Parameters.Add("@PostalCode", "90425") command.Parameters.Add("@Phone", "(415) 555-1234") command.Parameters.Add("@Fax", "(415) 555-1235") Console.WriteLine("Rows inserted: " + _ command.ExecuteNonQuery().ToString) Catch ex As Exception Console.WriteLine(ex.Message) Throw Finally connection.Close() End TryEnd Sub |
|
|
|
|
|
|
|