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 9143465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:02:04+00:00 2026-06-17T10:02:04+00:00

Hey I just started learning to make application in C# using back-end as sql.

  • 0

Hey I just started learning to make application in C# using back-end as sql.
I put some breakpoints to see that the control never comes back after executing the cntCeilInn.Open();
soon, the output window shows ‘System.Data.SqlClient.SqlException‘ occurred in System.Data.dll

Google tells me its not timing out or something that I couldn’t understand. Some help please.

string strServerName="EXPRESSION";

using (SqlConnection cntCeilInn = new SqlConnection("Data Source=" + strServerName + ";" + "Integrated Security=YES"))
{
    SqlCommand cmdCeilInn= new SqlCommand("If exists ("+ "Select name "+ "from sys.database "+ "Where name=N'CeilInn1')"+ "DROP database CeilInn1;"+ "go"+ "create database CeilInn1;", cntCeilInn);
    cntCeilInn.Open();
    cmdCeilInn.ExecuteNonQuery();
}
  • 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-17T10:02:05+00:00Added an answer on June 17, 2026 at 10:02 am

    There are few mistakes in your sql query .

    1. It’s sys.databases not sys.database

    2. No space between Go and Create syntax

    3. You need to place the sql statements in seperate line

    4. Not to mention do check your connection string once as others have stated

    Try this out

    SqlCommand cmdCeilInn = new SqlCommand("If exists (" + "Select name " + "from sys.databases " + "Where name=N'Sample') DROP database Sample;" 
                          +Environment .NewLine+ "go " + Environment .NewLine 
                         +" create database Sample;", cntCeilInn);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey, I've just started learning JavaScript and I'm making a little script that generates
Hey guys, I just started learning C++ and I have this code that I
hey this is so that I should just have put some infomation into the
Hey I just sort of learned how to put my SQL statements into VBA
Hey. I just started with Android. I'm using the ViewFlipper layout with 2 LinearLayouts.
Hey all. I just started looking into the cocos2d library. I've heard that it's
Hey, I just started wondering about this as I came upon a code that
Hey I just started dabbling with android programming, and from my short period of
Hey i'm just trying to write some code in DrScheme: ((function (x) (* x
hey guys I just started trying to convert my query structure to PDO and

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.