a) SqlCommand.ExecuteNonQuery is used for update, insert and delete operations.
Besides the fact that by using ExecuteNonQuery instead of ExecuteReader we automatically know there won't be any query results returned, are there some other benefits/reasons why ExecuteNonQuery should be used?
b) Similarly, if we want a database operation to return a single value, we should use ExecuteScalar instead of ExecuteNonquery ,where with the latter result would be returned via SqlParameter. Is there any particular reason why we should prefer ExecuteScalar over ExecuteNonQuery?
Possible Duplicate: In C#, should I use string.Empty or String.Empty or “” ? just don't understand the benefits of using String.Empty over "". Aside it being strongly typed its longer.
I think i understand the benefit of using themes but I want to be sure I understand correctly. I have previously used css to style my pages. I'm thinking about using themes in my next project. It provides a way to switch between the visual style of web controls and html elements. This could be done by allowing the user to choose a theme that is to their liking.
I would like to know what does a field timestamp in MSSQL do?I have read a book "ASP_NET_3_5_Social_Networking" and almost all the tabels have a columnt with type "timestamp" in their example app.What is the benefit of timestamp , and why should i use it?
I am new to OOP. Kindly guide me why making business objects is good ? how and what benefit they bring in development. As I am new to OOP if please you decidable with example in simple way will be great help to me.
1. .NET best practices, 2.best frameworks, and 3. benefits of the latest version?I need urgent help to convince the customer to use .NET, but they want me to list these 3 things. Can you help me list and/or point me to good summarized articles for these?
I am looking to build a web application for users to login and do various things on my website such as depositing money, withdrawal money, creating things that require money etc. I've heard MVC3 Linq and Entity Framework is a good way to build a asp.net c# web application, but I am confused because there are so many ways to build a web application,what is the most standard way to build a website, and what are the benefits of mvc3?
explain me or provide me with a links of good articles/tutorials on "Benefits AndLimitations of Service Oriented Architecture" ?I mean Where to Use and Where not, the SOA.
I come from a PHP/Rails background where deploying a website often means FTP/Checkout of the source code in the correct directory on the web server.
However, I've been asked to develop an ASP.NET website and some people have advised me to "Publish" the site instead of copying over the source code directly. Apparently, this converts the codebehind (.cs) files into compiled DLL's etc.
My application does not contain any specific secretive business logic. It's a common shopping cart app. My question is if this is a good idea? How does not making the C# code reside on the server make the app more secure?
In my application at some places we have used ObjectDataSource and at other normal method calls to retrieve data.My question is then what exactly are the benefits of using ObjectDataSource ?In the example below "CODE ONE" makes a call to the Business Layer and then Binds the results to the Grid abd "CODE TWO" is using ObjectDataSource to do the same.Then how is ObjectDataSource better?
SuitableApplicant sa = new SuitableApplicant(); IList<HD.Recruitment.SuitableApplicant> list = new List<HD.Recruitment.SuitableApplicant>(); list = HS.Recruitment.RecruitmentService.GetSuitableAppls(); GridView1.DataSource = list; [code]....
I have a gridview, where I have made autocode using the wizard. However I need a dynamic SQLcommand from server side. I have tried this code, but it doesn't work, it works if I use this code from HTML (setting the sqlcommand in the SQLDataSource. I have deleted the sqlcommand from the HTML and instead I have implemented the code in the page_load event:
Code:
Dim str As String = SqlDataSource1.SelectCommand = "SELECT DISTINCT Beregning.bId, Informationer.Dato,Beregning.bType, Informationer.pNavn, Informationer.pNr, Informationer.Beskr, Beregning.uId FROM Beregning CROSS JOIN Informationer WHERE (Beregning.UserId = @UserId) AND Beregning.uId = Informationer.uId AND (Beregning.bType=@berType2) ORDER BY Beregning.bId DESC" SqlDataSource1.SelectCommand = str But this code works, when I apply the SQLCommand in HTML:
I have another class that creates the connection (see refined class half way down page) and I believe it connects or at lest I do not hit any of the exceptions in run time.
I would now like to insert data into my database but nothing is updated.
I am trying to follow this example but it is for reading.
I did run "querystring" on the show SQL Pane and it does execute correctly. It inserts data properly as a new row.
I've got a routine that's supposed to be capturing data from an XML to a DataTable (which works fine), and then using that data to insert into MS SQL. I have no problems with the Inserting of records (via a different routine) but am struggling to update existing records - I'm not even getting any errors, and I can verify that the data is being assigned to the parameters.
Here's what I've got.
Shared Sub Sold(ByVal FullPath As String) Dim SQLSold As String Dim SC As New SqlConnection(CS) SQLSold = "Update Properties SET Status = @Status, Price = @Price WHERE UniqueID = @UniqueID" Dim DT As New DataTable
I have created a stored procedure that reset my tables' identity value. The store procedure works fine when I didrectly run it in my ms sql server 2008. It reset my table Identity value However, when I call it from my function reset, it returns -1, and does not reset my table identitity value. The function to restet my identity value is:
[Code]....
My stored procedure is
[Code]....
To call the the function:
Dim result As Integer = util.resetTableIdentity("myTable", "id", 60) util.print(result)
I got result is -1, and it does ot reset my table identity. Why? How to resove it?
Dim conn As SqlConnection = New SqlConnection("server='h'; user id='w'; password='w'; database='w'; pooling='false'") conn.Open() Dim query As New SqlCommand("DECLARE @investor varchar(10), @sql varchar(1000) Select @investor = 69836 select @sql = 'SELECT * FROM OPENQUERY(db,''SELECT * FROM table WHERE investor = ''''' + @investor + ''''''')' EXEC(@sql)", conn) dgBookings.DataSource = query.ExecuteReader dgBookings.DataBind()
I need to add in an If statement basically saying if the SQLCommand query returns no rows then show a specific label Can this be done?
I want to add array list in sqlcommand.but i don't no how to pass it. My code is.
ArrayList ProductId = new ArrayList(); for (int i = 0; i < ShipmentPackage.Items.Count; i++) { ProductId.Add(ShipmentPackage.Items[i].ProductVariant.ProductID); } select * from TableName where id= ProductId(ProductId is my Arraylist)