Click here to Skip to main content
15,886,199 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: Finding IP Address of Device Connected To PC via LAN Cable. Pin
VikashGohil16-May-09 21:42
VikashGohil16-May-09 21:42 
GeneralRe: Finding IP Address of Device Connected To PC via LAN Cable. Pin
Dave Kreskowiak17-May-09 3:27
mveDave Kreskowiak17-May-09 3:27 
Question[RESOLVED] Trying to use smo to create an insert stored proc which returns identity [modified] Pin
bobishkindaguy14-May-09 14:12
bobishkindaguy14-May-09 14:12 
AnswerRe: Trying to use smo to create an insert stored proc which returns identity Pin
Dave Kreskowiak15-May-09 4:15
mveDave Kreskowiak15-May-09 4:15 
GeneralRe: Trying to use smo to create an insert stored proc which returns identity Pin
led mike15-May-09 9:21
led mike15-May-09 9:21 
AnswerRe: Trying to use smo to create an insert stored proc which returns identity Pin
bobishkindaguy15-May-09 6:28
bobishkindaguy15-May-09 6:28 
GeneralRe: Trying to use smo to create an insert stored proc which returns identity Pin
Dave Kreskowiak15-May-09 12:05
mveDave Kreskowiak15-May-09 12:05 
QuestionRe: Trying to use smo to create an insert stored proc which returns identity [modified] Pin
bobishkindaguy17-May-09 9:39
bobishkindaguy17-May-09 9:39 
If I take the .TextBody string that this sub creates, and paste it into SQL Server Management Studio in a new Stored Procedure window, and press "Execute", the stored procedure is created perfectly.

If I run this sub, it fails.

(The mMyDatabase var is populated with a properly-connected database/connection.)

I've tried removing the BEGIN/END items, removing the parameters, changing the .TextMode, the .AnsiNullsStatus, the .QuotedIdentifierStatus, in every combination I can think of, and it still fails.

Thanks for any help!

Public Sub CreateInsertActivityStoredProcedure()

  Dim Name As String = "InsertActivityRow"
  If mMyDatabase.StoredProcedures.Contains(Name) Then
    mMyDatabase.StoredProcedures(Name).Drop()
  End If

  Dim An_SP As New StoredProcedure(mMyDatabase, Name, "dbo")

  'An_SP.TextHeader = "???"
  An_SP.TextMode = False
  An_SP.AnsiNullsStatus = False
  An_SP.QuotedIdentifierStatus = False

  'these are the input paramters
  An_SP.Parameters.Add(New StoredProcedureParameter(An_SP, "@UserFK", DataType.Int))
  An_SP.Parameters.Add(New StoredProcedureParameter(An_SP, "@MachineFK", DataType.Int))
  An_SP.Parameters.Add(New StoredProcedureParameter(An_SP, "@ActivityDate", DataType.DateTime))
  An_SP.Parameters.Add(New StoredProcedureParameter(An_SP, "@Activity", DataType.Int))
  An_SP.Parameters.Add(New StoredProcedureParameter(An_SP, "@TableAffected", DataType.Int))
  An_SP.Parameters.Add(New StoredProcedureParameter(An_SP, "@RowAffected", DataType.Int))

  'this is the output parameter
  Dim An_OutputParameter As StoredProcedureParameter = New StoredProcedureParameter(An_SP, "@NewPK", DataType.Int)
  An_OutputParameter.IsOutputParameter = True
  An_SP.Parameters.Add(An_OutputParameter)

  'start the string (the rest use += )
  An_SP.TextBody = ""

  An_SP.TextBody += "CREATE PROCEDURE InsertActivityRow"
  An_SP.TextBody += " @UserFK int,"
  An_SP.TextBody += " @MachineFK int,"
  An_SP.TextBody += " @ActivityDate datetime,"
  An_SP.TextBody += " @Activity int,"
  An_SP.TextBody += " @TableAffected int,"
  An_SP.TextBody += " @RowAffected int,"
  An_SP.TextBody += " @NewPK int OUT"
  An_SP.TextBody += " AS"
  An_SP.TextBody += " BEGIN"
  An_SP.TextBody += " SET NOCOUNT ON"
  An_SP.TextBody += " INSERT INTO ADV4SQL.dbo.ADVActivities"
  An_SP.TextBody += " ("
  An_SP.TextBody += " AcUserFK,"
  An_SP.TextBody += " AcMachineFK,"
  An_SP.TextBody += " AcDate,"
  An_SP.TextBody += " AcActivity,"
  An_SP.TextBody += " AcTableAffected,"
  An_SP.TextBody += " AcRowAffected"
  An_SP.TextBody += " )"
  An_SP.TextBody += " VALUES"
  An_SP.TextBody += " ("
  An_SP.TextBody += " @UserFK,"
  An_SP.TextBody += " @MachineFK,"
  An_SP.TextBody += " @ActivityDate,"
  An_SP.TextBody += " @Activity,"
  An_SP.TextBody += " @TableAffected,"
  An_SP.TextBody += " @RowAffected"
  An_SP.TextBody += " )"
  An_SP.TextBody += " SET @NewPK = SCOPE_IDENTITY() "
  An_SP.TextBody += " END"

  An_SP.Create()

End Sub


modified on Sunday, May 17, 2009 3:48 PM

AnswerRe: Trying to use smo to create an insert stored proc which returns identity Pin
bobishkindaguy17-May-09 10:57
bobishkindaguy17-May-09 10:57 
Questiontool text gdi+ Pin
ramaluciano14-May-09 4:59
ramaluciano14-May-09 4:59 
QuestionClickOnce and Sandbox? Pin
Atul Kharecha14-May-09 0:50
Atul Kharecha14-May-09 0:50 
Questionsplitting in VB.NET without delimiters Pin
poojapande13-May-09 23:06
poojapande13-May-09 23:06 
AnswerRe: splitting in VB.NET without delimiters Pin
Pete O'Hanlon13-May-09 23:24
mvePete O'Hanlon13-May-09 23:24 
GeneralRe: splitting in VB.NET without delimiters Pin
Luc Pattyn14-May-09 1:33
sitebuilderLuc Pattyn14-May-09 1:33 
AnswerRe: splitting in VB.NET without delimiters Pin
Fernando Soto14-May-09 8:28
Fernando Soto14-May-09 8:28 
QuestionDisable "Print" & "Save As" Options From Moss 2007 document Library Pin
Kronfolitto13-May-09 22:12
Kronfolitto13-May-09 22:12 
QuestionLink error with C++ code with Intel fortran code. Pin
lavate malllik13-May-09 21:47
lavate malllik13-May-09 21:47 
QuestionBootstrapper Pin
netDeveloper13-May-09 21:45
netDeveloper13-May-09 21:45 
AnswerRe: Bootstrapper Pin
netDeveloper13-May-09 22:50
netDeveloper13-May-09 22:50 
GeneralRe: Bootstrapper Pin
netDeveloper14-May-09 1:51
netDeveloper14-May-09 1:51 
QuestionWindows address book Pin
ashish purwar13-May-09 19:57
ashish purwar13-May-09 19:57 
QuestionDelete Record from Data Grid Pin
saif_saifi12-May-09 21:50
professionalsaif_saifi12-May-09 21:50 
Questionhow to paint the MainMenu Pin
coderormnger12-May-09 21:21
coderormnger12-May-09 21:21 
AnswerRe: how to paint the MainMenu Pin
Pete O'Hanlon12-May-09 22:08
mvePete O'Hanlon12-May-09 22:08 
QuestionHow to get machine certificate and user license. Pin
deadlyabbas12-May-09 21:01
deadlyabbas12-May-09 21:01 

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.