Guest User

Untitled

a guest
Oct 19th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.06 KB | None | 0 0
  1. SqlConnection cnstr = new SqlConnection(ConfigurationManager.ConnectionStrings["darconn"].ConnectionString);
  2. SqlCommand sqlcmd = new SqlCommand();
  3.  
  4. sqlcmd.CommandType = CommandType.StoredProcedure;
  5. sqlcmd.Connection = cnstr;
  6. sqlcmd.CommandText = "SetMapping";
  7.  
  8. String[] pullKodID = bundlelist.SelectedValue.ToString().Split(':');
  9. int kod_id = System.Convert.ToInt32(pullKodID[0]);
  10.  
  11. sqlcmd.Parameters.Add("@kod_id", kod_id);
  12. sqlcmd.Parameters.Add("@ell_id", courselist.Items[i].Text);
  13. cnstr.Open();
  14. sqlcmd.ExecuteNonQuery();
  15. cnstr.Close();
  16.  
  17. sqlcmd.CommandText = "dbo.SetMapping";
  18.  
  19. -------------------------------------------------------------------------
  20. -- Check Syntax of Database Objects
  21. -- Copyrighted (2009). Free to use as a tool to check your own code or in
  22. -- any software not sold. All other uses require written permission from Author
  23. -- Author: Stephen Schaff
  24. -------------------------------------------------------------------------
  25. -- Turn on ParseOnly so that we don't actually execute anything.
  26. SET PARSEONLY ON
  27. GO
  28.  
  29. -- Create a table to iterate through
  30. declare @ObjectList table (ID_NUM int NOT NULL IDENTITY (1, 1), OBJ_NAME varchar(255), OBJ_TYPE char(2))
  31.  
  32. -- Get a list of most of the scriptable objects in the DB.
  33. insert into @ObjectList (OBJ_NAME, OBJ_TYPE)
  34. SELECT name, type
  35. FROM sysobjects WHERE type in ('P', 'FN', 'IF', 'TF', 'TR', 'V')
  36. order by type, name
  37.  
  38. -- Var to hold the SQL that we will be syntax checking
  39. declare @SQLToCheckSyntaxFor varchar(max)
  40. -- Var to hold the name of the object we are currently checking
  41. declare @ObjectName varchar(255)
  42. -- Var to hold the type of the object we are currently checking
  43. declare @ObjectType char(2)
  44. -- Var to indicate our current location in iterating through the list of objects
  45. declare @IDNum int
  46. -- Var to indicate the max number of objects we need to iterate through
  47. declare @MaxIDNum int
  48. -- Set the inital value and max value
  49. select @IDNum = Min(ID_NUM), @MaxIDNum = Max(ID_NUM)
  50. from @ObjectList
  51.  
  52. -- Begin iteration
  53. while @IDNum <= @MaxIDNum
  54. begin
  55. -- Load per iteration values here
  56. select @ObjectName = OBJ_NAME, @ObjectType = OBJ_TYPE
  57. from @ObjectList
  58. where ID_NUM = @IDNum
  59.  
  60. -- Get the text of the db Object (ie create script for the sproc)
  61. SELECT @SQLToCheckSyntaxFor = OBJECT_DEFINITION(OBJECT_ID(@ObjectName, @ObjectType))
  62.  
  63. begin try
  64. -- Run the create script (remember that PARSEONLY has been turned on)
  65. EXECUTE(@SQLToCheckSyntaxFor)
  66. end try
  67. begin catch
  68. -- See if the object name is the same in the script and the catalog (kind of a special error)
  69. if (ERROR_PROCEDURE() <> @ObjectName)
  70. begin
  71. print 'Error in ' + @ObjectName
  72. print ' The Name in the script is ' + ERROR_PROCEDURE()+ '. (They don''t match)'
  73. end
  74.  
  75. end catch
  76.  
  77. -- Setup to iterate to the next item in the table
  78. select @IDNum = case
  79. when Min(ID_NUM) is NULL then @IDNum + 1
  80. else Min(ID_NUM)
  81. end
  82. from @ObjectList
  83. where ID_NUM > @IDNum
  84.  
  85. end
  86. -- Turn the ParseOnly back off.
  87. SET PARSEONLY OFF
  88. GO
  89.  
  90. else if (ERROR_MESSAGE() <> 'There is already an object named ''' + ERROR_PROCEDURE() + ''' in the database.')
  91. begin
  92. -- Report the error that we got.
  93. print 'Error in ' + ERROR_PROCEDURE()
  94. print ' ERROR TEXT: ' + ERROR_MESSAGE()
  95. end
  96.  
  97. [global::System.Data.Linq.Mapping.FunctionAttribute(Name="dbo.GetSomeInformation", IsComposable=true)]
  98. public IQueryable<GetSomeInformationResult> GetSomeInformation([global::System.Data.Linq.Mapping.ParameterAttribute(DbType="BigInt")] System.Nullable<long> infoId)
  99. {
  100. return this.CreateMethodCallQuery<GetSomeInformationResult>(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), infoId);
  101. }
  102.  
  103. [global::System.Data.Linq.Mapping.FunctionAttribute(Name="dbo.GetSomeInformation")]
  104. public ISingleResult<GetSomeInformationResult> GetSomeInformation([global::System.Data.Linq.Mapping.ParameterAttribute(DbType="BigInt")] System.Nullable<long> infoId)
  105. {
  106. IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), infoId);
  107. return ((ISingleResult<GetSomeInformationResult>)(result.ReturnValue));
  108. }
Add Comment
Please, Sign In to add comment