Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 28th, 2004, 05:31 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 146
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to aadz5
Default Stored Procedures

Hiya Guys,

I am using System.Data.SqlClient for the first time and wrote this code to create a stored procedure but I keep getting this error: -

An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll

Additional information: System error.

This is my code: -

SqlConnection objConnection;
            string strSQL;
            SqlCommand objCommand;

            objConnection = new SqlConnection("Data Source=(local)\\NetSDK; Initial Catalog=NorthWind; Integrated Security = true");

            objConnection.Open();
            strSQL = "CREATE PROCEDURE sp_WaCustomers AS SELECT CustomerID, CustomerName FROM Customers WHERE Region = 'WA'";
            objCommand = new SqlCommand(strSQL, objConnection);
            objCommand.CommandType = CommandType.StoredProcedure;
            objCommand.ExecuteNonQuery();
            Console.WriteLine("Procedure Created !!");

Any ideas??



Adz - The World is not enough
__________________
Adz - Learning The J2EE Ways.
 
Old April 28th, 2004, 11:47 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

Dear friend:
ur command (strSQL) is not wrong but I think u get this error bc of 3 reason.
1_ I see no user & pass in ur Connection string to connect user(objConnection).
2_ Ensure u r going to execute the command for not first time & SP is already created.
3_ U might have no primission to create SP on server.

START FROM #1.
HTH, Keep in touch.

Always:),
Hovik Melkomian.
 
Old April 29th, 2004, 03:31 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 146
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to aadz5
Default

What should the connection string be if the SQL Database using the windows authentication as user name and password??

Adz - The World is not enough
 
Old April 29th, 2004, 04:01 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 146
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to aadz5
Default

Hi,

I have changed my connection string, but I am still getting the same error??

this is my code: -

SqlConnection objConnection;
            string strSQL;
            SqlCommand objCommand;

            objConnection = new SqlConnection("Data Source=(local)\\NetSDK; Initial Catalog=NorthWind; uid=QSUser; pwd=QSPassword; Integrated Security=SSPI");

            objConnection.Open();
            strSQL = "CREATE PROCEDURE sp_WaCustomers AS SELECT CustomerID, CustomerName FROM Customers WHERE Region = 'WA'";
            //strSQL = "SELECT * FROM CustomerID";
            objCommand = new SqlCommand(strSQL, objConnection);
            objCommand.CommandType = CommandType.StoredProcedure;
            objCommand.ExecuteNonQuery();
            Console.WriteLine("Procedure Created !!");

Any Ideas??

Adz - The World is not enough
 
Old May 1st, 2004, 02:40 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

dear freind:
u r creating SP not using SP so ur comand is Test & u should set ur CommandType to
Code:
objCommand.CommandType = CommandType.Text;


HTH.

Always:),
Hovik Melkomian.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Stored Procedures KeviJay VB Databases Basics 1 June 5th, 2008 07:17 AM
stored procedures MunishBhatia SQL Server 2005 4 April 12th, 2008 01:39 AM
STORED PROCEDURES shazia1 SQL Server ASP 7 September 26th, 2007 06:11 AM
Stored Procedures itHighway SQL Server 2000 3 November 23rd, 2005 10:08 AM
Stored Procedures stu9820 Access 3 February 8th, 2004 01:13 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.