Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET 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 January 28th, 2007, 12:05 PM
Authorized User
 
Join Date: Jan 2007
Posts: 46
Thanks: 2
Thanked 1 Time in 1 Post
Default Connection Error: Please Help

I have the following code in my Visual Studio.Net editor:

SqlConnection1.Open()
        ' Dim MySqlConn As New SqlClient.SqlConnection("Server=Maxood;User ID=sa;Password=;Database=Businesses")
        Dim MySqlCmd As New SqlClient.SqlCommand




        MySqlCmd.CommandType = CommandType.Text
        MySqlCmd.Connection = SqlConnection1

        MySqlCmd.CommandText = "INSERT INTO buss_seg values('" & txtEntry.Text & "')"
        MySqlCmd.ExecuteNonQuery()

        SqlConnection1.Close()
When i execute this code , the following error occurs:

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

Additional information: System error.

What is the reason.Why it happened, please help!

MAXOOD!

Life is an endless journey towards perfection
__________________
MAXOOD!

Life is an endless journey towards perfection
 
Old January 28th, 2007, 09:59 PM
Friend of Wrox
 
Join Date: May 2005
Posts: 227
Thanks: 1
Thanked 7 Times in 7 Posts
Default

code_lover:
If the code below is what you executed then where are:
   1- the Import Namespace statements for System.Data and System.Data.SqlClient;
   2- the Sub Page_Load statement;
 Send complete code.
   3- check to on the line, .ExecuteNonQuery try .ExecuteScalar().

Hope this helps.
 
Old February 6th, 2007, 07:18 AM
Registered User
 
Join Date: Feb 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

imports system.data.sqlclient

and then remove sqlclient below the code.
eg:
replace sqlclient.sqlcommand as sqlcommand

 
Old February 6th, 2007, 10:12 PM
Friend of Wrox
 
Join Date: May 2005
Posts: 227
Thanks: 1
Thanked 7 Times in 7 Posts
Default

I asked where were the import directives?
<%@ Import namespace="System.Data" %>
<%@ Import namespace="System.Data.SqlClient" %>

What book(s) are you following?





Similar Threads
Thread Thread Starter Forum Replies Last Post
Connection Error asters .NET Framework 1.x 3 April 4th, 2008 12:46 AM
Connection Error kingroon Classic ASP Basics 3 January 10th, 2008 08:48 PM
Connection Error zaghmout ASP.NET 2.0 Professional 3 October 31st, 2007 01:55 AM
connection error jigsy ADO.NET 1 May 22nd, 2007 08:00 AM
connection error janees ASP.NET 2.0 Professional 1 March 2nd, 2007 02:26 PM





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