473,320 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

StoredProcedures

Hi..
Can anyone help in this..
I have created a stored procedure for inserting values in SQLserver2000, coming to frontend i have forms in asp.net with VB.net lang.
I need to call the stored procedure here.I have created connection string and command object.Now how to execute the stored procedure from the button click event??The values are entered through front end and it should store them in database using the procedure.
Can anyone please reply me on these
Apr 19 '07 #1
3 1059
Frinavale
9,735 Expert Mod 8TB
Hi..
Can anyone help in this..
I have created a stored procedure for inserting values in SQLserver2000, coming to frontend i have forms in asp.net with VB.net lang.
I need to call the stored procedure here.I have created connection string and command object.Now how to execute the stored procedure from the button click event??The values are entered through front end and it should store them in database using the procedure.
Can anyone please reply me on these
Hi there!

Try doing something like:
Expand|Select|Wrap|Line Numbers
  1. Public Sub InsertCustomer()
  2.     Dim connection As SqlConnection = _
  3.         New SqlConnection(connectionString)
  4.     connection.Open()
  5.     Try
  6.         Dim command As SqlCommand = _
  7.             New SqlCommand("InsertCustomer", connection)
  8.         command.CommandType = CommandType.StoredProcedure
  9.  
  10.         command.Parameters.Add("@CustomerID", "PAULK")
  11.         command.Parameters.Add("@CompanyName", "Pauly's Bar")
  12.         command.Parameters.Add("@ContactName", "Paul Kimmel")
  13.         command.Parameters.Add("@ContactTitle", "The Fat Man")
  14.         command.Parameters.Add("@Address", "31025 La Jolla")
  15.         command.Parameters.Add("@City", "Inglewood")
  16.         command.Parameters.Add("@Region", "CA")
  17.         command.Parameters.Add("@Country", "USA")
  18.         command.Parameters.Add("@PostalCode", "90425")
  19.         command.Parameters.Add("@Phone", "(415) 555-1234")
  20.         command.Parameters.Add("@Fax", "(415) 555-1235")
  21.  
  22.         Console.WriteLine("Rows inserted: " + _
  23.                           command.ExecuteNonQuery().ToString)
  24.  
  25.         Catch ex As Exception
  26.             Console.WriteLine(ex.Message)
  27.             Throw
  28.         Finally
  29.             connection.Close()
  30.         End Try
  31. End Sub
  32.  
The example posted here was taken from this website, check it out if you would like more information.

-Frinny
Apr 19 '07 #2
Hi!!

Thanks for the reply.
The code which you have sent me is in c#, but anyways i tried the same in VB.net.
I get the error saying server doesnot exist by highlighting the "Conn.Open()"
I am not able to resolve this problem.
Could you help me??
Apr 20 '07 #3
Frinavale
9,735 Expert Mod 8TB
Hi!!

Thanks for the reply.
The code which you have sent me is in c#, but anyways i tried the same in VB.net.
I get the error saying server doesnot exist by highlighting the "Conn.Open()"
I am not able to resolve this problem.
Could you help me??
Could you copy the exact error that you're getting and post it here.
It'd be helpful if I saw more detail on the error.

-Frinny

(PS. the code supplied is written in VB.NET)
Apr 20 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: sbw | last post by:
Hi. I have an app which uses multiple databases and I would like to know if there is a way to connect to different databases through OLEdb (or any other connection string) which allows me to...
4
by: dickson.matt | last post by:
Anyone know of a way to enumerate the argument list of a function in VB.NET. For example I have a Function add_user (u_id AS INT, u_first_name AS VARCHAR(50), u_last_name AS VARCHAR(50)). I...
11
by: jw56578 | last post by:
what is a common method, if any, to retrieve stored query information from Access. MDAC does not support OleDbSchemaGuid.Procedure_Columns. I need stored procedure name and paramter information,...
3
by: Renato Vieira | last post by:
I get the error 'Procedure 'spBO_HeadlineCreate' expects parameter '@imageid', which was not supplied' when i call the procedure with the @imageid=null, but id the @imageid as a diff. value no...
7
by: dipper | last post by:
Anyone have an example with stored procedure with Microsoft SQL server? I need an example with argument and return value. Posted Via Usenet.com Premium Usenet Newsgroup Services...
1
by: Fabio Cavassini | last post by:
Hi, I have made a method in Global.asax called from Application_Start event that loads some cache data from database to Application scope objets. This is necessary because this is some data...
3
by: taru | last post by:
Env: DB2 UDB 8.1 on AIX We are executing a db2 sql stored procedure which is invoked from a java client. The stored procedure contains few select, insert and update statements. Using the DB2...
1
by: ShanthaKumar | last post by:
When i was Filling My Datagrid, i juz Configured SqlDataSource with the Update Command Based Stored Procedure Where the Stored Procedures Contains Three Tables to Update? Whether it is Possible Or...
5
by: nidaar | last post by:
From a security point of view, is accepting wildcards like "%" in input parameters of stored procedures against any best practices? As an example, if a user defined function uses "Productname...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.