Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7971911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:44:05+00:00 2026-06-04T07:44:05+00:00

I am using SQLDataAdapter to run a script. Script is as below, ALTER TABLE

  • 0

I am using SQLDataAdapter to run a script. Script is as below,

ALTER TABLE dbo.Table1 SET (LOCK_ESCALATION = TABLE)
GO
COMMIT
select Has_Perms_By_Name(N'dbo.Table1', 'Object', 'ALTER') as ALT_Per, Has_Perms_By_Name(N'dbo.Table1', 'Object', 'VIEW DEFINITION') as View_def_Per, Has_Perms_By_Name(N'dbo.Table1', 'Object', 'CONTROL') as Contr_Per BEGIN TRANSACTION
GO
ALTER TABLE dbo.Table2
DROP CONSTRAINT DF_Table2
GO

It is giving me error as Incorrect syntax near GO. If I remove GO from the query text, it works fine. But I need to execute this script only.

Here is a c# code. QueryText is a string which contains the entire query along with the SET and GO.

DataSet ds = new DataSet();
SqlConnection conn = new SqlConnection(_connectionString);
SqlDataAdapter da = new SqlDataAdapter(QueryText, conn);
da.Fill(ds);

Does anyone know how to go with it.

Thanks in advance,

Vijay

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T07:44:06+00:00Added an answer on June 4, 2026 at 7:44 am

    GO is a marker for Management Studio or other SQLServer command lines tools and serve as final delimiter to send a batch of commands to SQL Server.
    In your code, you need to replicate this behavior.
    Separate the script in subparts using the GO as delimiter.
    Send each part using a single command (for the ALTER TABLE) and use your SqlDataAdapter for the SELECT part.
    Also you should remove the COMMIT and BEGIN TRANSACTION from the script parts and use, inside your code, the SqlTransaction object from the SqlConnection.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What are the differences between using SqlDataAdapter vs SqlDataReader for getting data from a
I want to insert a row into the Database using SqlDataAdapter. I've 2 tables
Using PHP, I can convert MySQL data or static table data to csv, Excel,
I'm using adapter.InsertCommand to insert some data into a table. The only problem is
I'm using SqlDataAdapter.Update with DataTables to update two SQL tables in a single transaction.
I've imported a DataTable from a SQL Database using SqlDataAdapter and Fill-Method. My datatable
This question comes from a code analysis run against an object I've created. The
I have to run a SQL query using a text value in a label
I have two columns syntax and query in my table Table1 . Syntax contains
I have the following piece of code: if (SqlConnection.State == ConnectionState.Open) { using (SqlDataAdapter

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.