p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 28th, 2004, 06:31 PM
Friend of Wrox
Points: 584, Level: 8
Points: 584, Level: 8 Points: 584, Level: 8 Points: 584, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2003
Location: Portsmouth, Hampshire, United Kingdom.
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
  #2 (permalink)  
Old April 29th, 2004, 12:47 AM
Friend of Wrox
Points: 3,152, Level: 23
Points: 3,152, Level: 23 Points: 3,152, Level: 23 Points: 3,152, Level: 23
Activity: 20%
Activity: 20% Activity: 20% Activity: 20%
 
Join Date: Jun 2003
Location: Tehran, Iran
Posts: 922
Thanks: 0
Thanked 1 Time in 1 Post
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
  #3 (permalink)  
Old April 29th, 2004, 04:31 PM
Friend of Wrox
Points: 584, Level: 8
Points: 584, Level: 8 Points: 584, Level: 8 Points: 584, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2003
Location: Portsmouth, Hampshire, United Kingdom.
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
  #4 (permalink)  
Old April 29th, 2004, 05:01 PM
Friend of Wrox
Points: 584, Level: 8
Points: 584, Level: 8 Points: 584, Level: 8 Points: 584, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2003
Location: Portsmouth, Hampshire, United Kingdom.
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
  #5 (permalink)  
Old May 1st, 2004, 03:40 AM
Friend of Wrox
Points: 3,152, Level: 23
Points: 3,152, Level: 23 Points: 3,152, Level: 23 Points: 3,152, Level: 23
Activity: 20%
Activity: 20% Activity: 20% Activity: 20%
 
Join Date: Jun 2003
Location: Tehran, Iran
Posts: 922
Thanks: 0
Thanked 1 Time in 1 Post
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
 


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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Stored Procedures KeviJay VB Databases Basics 1 June 5th, 2008 08:17 AM
stored procedures MunishBhatia SQL Server 2005 4 April 12th, 2008 02:39 AM
STORED PROCEDURES shazia1 SQL Server ASP 7 September 26th, 2007 07: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



All times are GMT -4. The time now is 02:17 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc