Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 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 December 2nd, 2005, 02:30 PM
Authorized User
 
Join Date: Nov 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default SQL ERROR IN C#

 I'm working on creating a database using SQL server, and my code is written in VS.NET. I get the following error:

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

Additional information: System error.
---------------------------

Here is the function where the 1st error takes place:

------------------------
public static int ExecuteNonQuery (string procName, params object[] args) {

      SqlCommand cmnd = null;
        try
        {
            // Run the stored procedure to update the database
            cmnd = DbUtil.BuildCommand(procName, args);
            cmnd.Connection.Open();
            int iRowsAffected = cmnd.ExecuteNonQuery();

            // return the number of rows affected
            return iRowsAffected;
        }

        finally
        {
            // Close resources
            if (cmnd != null)
                if (cmnd.Connection.State != ConnectionState.Closed)
                    cmnd.Connection.Close();
        }

    }
----------------------

I think the problem has something to do with my connection string. I'm not sure if I wrote the connection string correctly. Here it is:
_DSN = "Data Source=132.47.120.194;User ID=sa;Password=par>05sql;Database=Jodiv;";

If anyone has any suggestions please reply back!!!

 
Old December 3rd, 2005, 10:46 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

If the connection is wrong you should get a pretty obvious error message:
"SQL Server cannot be found."
"Login bad..."

Unfortunately, "System error" is vague and doesn't help much.

-Peter
 
Old December 8th, 2005, 02:07 AM
Friend of Wrox
 
Join Date: Feb 2004
Posts: 177
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Can you catch the expection text and past it here?

It is not how much we do,
but how much love we put in the doing.

-Mother Theresa
 
Old December 8th, 2005, 02:32 AM
Authorized User
 
Join Date: Nov 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the response! It has been resolved.

 
Old December 10th, 2005, 11:46 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Could you tell us what you did to resolve it?

-Peter
 
Old December 11th, 2005, 12:35 AM
Authorized User
 
Join Date: Nov 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Um...I can't really remember exactly. I think the problem was something stupid like I was running my script file through the wrong database. :)






Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Server Reg. SQL Server does not exist error Arsi SQL Server 2000 1 June 11th, 2008 11:20 AM
error sql! hamai VS.NET 2002/2003 0 April 20th, 2007 04:14 PM
SQL Error. akhilhp ASP.NET 2.0 Basics 1 January 23rd, 2007 08:46 AM
SQL Error fs22 ASP.NET 2.0 Basics 1 August 2nd, 2006 01:07 AM
ANY HELP WITH SQL??? ERROR koco ASP.NET 1.0 and 1.1 Basics 1 June 8th, 2006 09:13 AM





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