XSD Parser Error Message: Failed to generate code. Exception of type 'System.Data.Design.InternalException'

visual-studio

(afree) #1

I get this error in visual studio:

Parser Error Message: Failed to generate code. Exception of type ‘System.Data.Design.InternalException’ was thrown.

at this Line 1:

<?xml version="1.0" encoding="utf-8"?>

I get that error after creating a DataAdapter and add it to the XSD file.

thanks for advice!


(SAM) #2

The Issue:

I had similar exception many times, that exception occurs usually when you create your dataset using the Drag & Drop functionality in Visual Studio, either dragging your Dataset from the server explorer panel or from a database within your project. and then once you Remove, Rename that referenced Database (or is not accessible anymore for any reason) that exception will occur:

Parser Error Message: Failed to generate code. Exception of type ‘System.Data.Design.InternalException’ was thrown.

it can be for other reasons but as said that’s the common case for me.

How to Solve It:

Now to solve the issue is all you need to do is this:

  1. Right click your Dataset in the project explorer, choose “Run Custom Tool” and select the Text Editor.
  2. Once opened your dataset in a text editor, go through it until you find a “Connection” node.
  3. the “connection” node has a “ConnectionStringObject” attribute that points to the old Database connection string.
  4. Change that connection string to the appropriate one that works.
  5. Save your changes, it should work now.

that’s it.