Click here to Skip to main content
15,893,622 members
Home / Discussions / C#
   

C#

 
AnswerRe: SQL Server and C# Pin
BobJanova1-Dec-11 1:46
BobJanova1-Dec-11 1:46 
GeneralRe: SQL Server and C# Pin
john john mackey1-Dec-11 11:23
john john mackey1-Dec-11 11:23 
AnswerRe: SQL Server and C# Pin
jschell1-Dec-11 13:50
jschell1-Dec-11 13:50 
QuestionC# desktop controls Pin
classy_dog30-Nov-11 6:19
classy_dog30-Nov-11 6:19 
AnswerRe: C# desktop controls Pin
fjdiewornncalwe30-Nov-11 8:39
professionalfjdiewornncalwe30-Nov-11 8:39 
AnswerRe: C# desktop controls Pin
BillWoodruff30-Nov-11 14:22
professionalBillWoodruff30-Nov-11 14:22 
QuestionHow do I make Post Publish Tasks work? DLL is locked? Pin
KevonHoughton30-Nov-11 5:37
KevonHoughton30-Nov-11 5:37 
Questionrun sql script in C# Pin
jojoba201130-Nov-11 0:09
jojoba201130-Nov-11 0:09 
When i wanna to run script of create/Alter View i get the following error :

My Source is :

C#
SqlConnection con = new SqlConnection(conString);
            SqlCommand cmd = new SqlCommand();
            try
            {

                string command = @"create view d_jest
as
SELECT     dbo.AccDocumentDetailsVosoolBargasht.VosoolBargashtId, dbo.AccDocumentDetailsVosoolBargasht.AccDocumentDetailsId, 
                      dbo.VosoolBargasht.GhabzDetailsId, dbo.VosoolBargasht.Type, dbo.AccDocumentDetail.AccDocumentID
FROM         dbo.AccDocumentDetailsVosoolBargasht INNER JOIN
                      dbo.VosoolBargasht ON dbo.AccDocumentDetailsVosoolBargasht.VosoolBargashtId = dbo.VosoolBargasht.ID INNER JOIN
                      dbo.AccDocumentDetail ON dbo.AccDocumentDetailsVosoolBargasht.AccDocumentDetailsId = dbo.AccDocumentDetail.ID
                      
Go

Create view d_kest
  as
  SELECT     dbo.AccDocumentDetail.AccDocumentID, dbo.AccdocumentDetailsTafsiliShenavar.TafsiliShenavarId, 
                      dbo.AccdocumentDetailsTafsiliShenavar.AccDocumentDetailId, dbo.AccdocumentDetailsTafsiliShenavar.ID, dbo.TafsiliShenavar.Name, 
                      dbo.TafsiliShenavar.Code
FROM         dbo.AccdocumentDetailsTafsiliShenavar INNER JOIN
                      dbo.TafsiliShenavar ON dbo.AccdocumentDetailsTafsiliShenavar.TafsiliShenavarId = dbo.TafsiliShenavar.ID INNER JOIN
                      dbo.AccDocumentDetail ON dbo.AccdocumentDetailsTafsiliShenavar.AccDocumentDetailId = dbo.AccDocumentDetail.ID                    
Go                      ";
                cmd.CommandText = command;
                cmd.Connection = con;
                con.Open();
                int result = cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            if (con.State == ConnectionState.Open)
                con.Close();


I get this error :

Incorrect syntax near 'GO'<br />
'CREATE VIEW' must be the first statement in a query batch.<br />
Incorrect syntax near 'GO'


but if i run this script directly in sql i wont get an error and every thing is right there.
AnswerRe: run sql script in C# Pin
Pete O'Hanlon30-Nov-11 0:17
mvePete O'Hanlon30-Nov-11 0:17 
QuestionRe: run sql script in C# <code>new</code> Pin
jojoba201130-Nov-11 0:22
jojoba201130-Nov-11 0:22 
AnswerRe: run sql script in C# new Pin
Pete O'Hanlon30-Nov-11 0:38
mvePete O'Hanlon30-Nov-11 0:38 
QuestionRe: run sql script in C# new Pin
jojoba201130-Nov-11 0:47
jojoba201130-Nov-11 0:47 
AnswerRe: run sql script in C# new Pin
Pete O'Hanlon30-Nov-11 0:56
mvePete O'Hanlon30-Nov-11 0:56 
QuestionRe: run sql script in C# new Pin
jojoba201130-Nov-11 0:58
jojoba201130-Nov-11 0:58 
AnswerRe: run sql script in C# new Pin
Pete O'Hanlon30-Nov-11 1:00
mvePete O'Hanlon30-Nov-11 1:00 
QuestionRe: run sql script in C# new Pin
jojoba201130-Nov-11 1:02
jojoba201130-Nov-11 1:02 
AnswerRe: run sql script in C# new PinPopular
Pete O'Hanlon30-Nov-11 1:07
mvePete O'Hanlon30-Nov-11 1:07 
GeneralRe: run sql script in C# new Pin
jojoba201130-Nov-11 1:09
jojoba201130-Nov-11 1:09 
GeneralRe: run sql script in C# new Pin
Pete O'Hanlon30-Nov-11 1:14
mvePete O'Hanlon30-Nov-11 1:14 
QuestionRe: run sql script in C# new Pin
jojoba201130-Nov-11 17:54
jojoba201130-Nov-11 17:54 
AnswerRe: run sql script in C# new Pin
Dave Kreskowiak1-Dec-11 4:11
mveDave Kreskowiak1-Dec-11 4:11 
AnswerRe: run sql script in C# Pin
jschell30-Nov-11 10:16
jschell30-Nov-11 10:16 
QuestionMicrosoft Interop Word Winforms issue on CITRIX Pin
spankyleo12330-Nov-11 0:00
spankyleo12330-Nov-11 0:00 
AnswerRe: Microsoft Interop Word Winforms issue on CITRIX Pin
Richard MacCutchan30-Nov-11 3:11
mveRichard MacCutchan30-Nov-11 3:11 
GeneralRe: Microsoft Interop Word Winforms issue on CITRIX Pin
spankyleo12330-Nov-11 23:12
spankyleo12330-Nov-11 23:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.