why different syntaxes in Commnad lines?

dotnet framework

    Next

  • 1. executescalar() method
    Dear .NET Programmers, I use the following code snippet but can't figure out what is going wrong since the result object equals to nothing although it shouldn't be :) Function CheckMFileToBeClosed() As Boolean Dim result As Object myCommand.Parameters.Clear() myCommand.CommandText = "SELECT Result = CASE WHEN DischargeDate IS NULL THEN 1 " & _ "ELSE 0 END " & _ "FROM dbo.MedicalFollowUpInHospital " & _ "WHERE OurFileNo = @medicalFileNo" myCommand.CommandType = CommandType.Text myCommand.Parameters.Add("@medicalFileNo", Session("selectedFileNumber") + "M") result = myCommand.ExecuteScalar() If CInt(result) = 1 Then Return False Else Return True End If End Function Thanks in advance, Buran
  • 2. transaction and command builder
    Hi, I am getting the following exception when trying to update a dataset using data adapater and a command builder: "Execute requires the command to have a transaction object when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized." Here is the code: DataSet oDS = ...; OleDbConnection oConnection = ...; OleDbTransaction oTransaction = ...; // without this line it works... oTransaction = oConnection.BeginTransaction(); OleDbDataAdapter oDA = null; OleDbCommandBuilder oCmdBuilder = null; oDA = new OleDbDataAdapter("SELECT * FROM " + oDS.Tables [0].TableName, oConnection); DataSet oChangesDS = oDS.GetChanges(); if (oChangesDS != null) { oCmdBuilder = new OleDbCommandBuilder(oDA); oCmdBuilder.QuotePrefix = "["; oCmdBuilder.QuoteSuffix = "]"; oDA.Update(oDS, oDS.Tables[0].TableName); oDS.AcceptChanges(); } ... If I don't start transaction, everything works. I tried setting the transaction property of the command builder: oCmdBuilder.GetUpdateCommand().Transaction = oTransaction; and/or Transaction of data adapter: oDA.SelectCommand.Transaction = oTransaction; No luck. Please help. Thanks, VR

why different syntaxes in Commnad lines?

Postby phil » Sun, 04 Jun 2006 00:55:40 GMT

Hi,

I saw three different syntaxes in command lines:
UpdateCommand="UPDATE [mytable] SET [name] = @name ...
UpdateCommand="Update `mytable` set `name`=? ...
UpdateCommand="UPDATE [mytable] SET [name] = ? ...

Does the three do the same?
Why those differences?
Thanks
Phil




Re: why different syntaxes in Commnad lines?

Postby Mary Chipman [MSFT] » Tue, 06 Jun 2006 03:36:25 GMT

It depends on which data provider and data source you are using. See
 http://www.**--****.com/ 
information.

--Mary





Re: why different syntaxes in Commnad lines?

Postby phil » Tue, 06 Jun 2006 21:46:17 GMT

Thanks









Similar Threads:

1.findcontrol("PlaceHolderPrice") why why why why why why why why why why why

why why why why why why why why why why why

Can't i get

dim PlaceHolderPrice as placeholder = 
formview1.findcontrol("PlaceHolderPrice")



<asp:FormView ID="FormView1" runat="server" DataKeyNames="AdNum" 
DefaultMode="Edit" DataSourceID="SqlDataSource1">

<EmptyDataTemplate>



</EmptyDataTemplate>

<EditItemTemplate>

<table border="0" cellspacing="0" cellpadding="0" width="550" >

<asp:PlaceHolder ID="PlaceHolderPrice" runat="server" Visible="false">

<tr>

<td style="width: 3px;" valign="top">

</td>

<td valign="top">

Price:

</td>

<td valign="top" width="10">

$</td>

<td valign="top">

<asp:TextBox ID="PriceTextBox" runat="server" Text='<%# Bind("Price") 
%>'></asp:TextBox>

td>

<td width="10">

 </td>

</tr>

</asp:PlaceHolder>


</table>

</editItemTemplate>

</formview>


2.Why do I get different value on two different computers

Hi!

At the bottom is a simple thread program.
If I run this program on a computer that doesn't have two cores I always
get 100010 which is correct.
If I run this program on a computer that have two cores I sometimes get a
value that could be 96542 or 97129 or something else that less that 100010.
This is because of not doing for example lock or interlocked in this 
example.

So my question is why do I always get the correct result when I run the 
program on a computer with only one core ??
This computer with only one core is very old perhaps 10 years.

Class Test
{
   static void UpdateCount()
   {
        for (int x = 0; x <= 10000; x++)
            Counter.count = Counter.count + 1;
   }

   public static void Main()
   {
      ThreadStart starter = new ThreadStart(UpdateCount);
      Thread[] threads = new Thread[10];

      for (int x = 0; x < 10; x++)
      {
         threads[x] = new Thread(starter);
         threads[x].Start();
      }

      for (int x = 0; x < 10; x++)
      {
         threads[x].Join();
      }

      Console.WriteLine("Total: {0}", Counter.count);
      Console.ReadLine();
   }
}

//Tony


3.why why why why why

when i open a datasource, does the database get passed bfrom me to the 
server, and I have to sit and wait

why why why 


4..net beta 2 msbuild commnad not recognized

I just installed .net beta 2. 
But now as i try to run msbuild from my msbuild project root directory 
(visual studio 2005 command prompt) , i get the following error

'msbuild' is not recognized as an internal or external command,
operable program or batch file.

Any clues?


5.bind commnad to 1 transaction object

Hi all

Can someone please tell me how I can successfully "bind" multiple INSERT command objects(for example) - that are from different DataAdapters - to execute under one transaction object. i.e I have 4 insert command objects that insert data into 4 different tables and if the insert happens to fail on any one of the tables, I want the entire insert acroos those tables to be rolled back

How do I do this

TIA for any hel

Kevin

6. Q: Newbee question, regarding a couple of syntaxes in c#

7. Newbee question, regarding a couple of syntaxes in c#

8. Adding commnad to context menu



Return to dotnet framework

 

Who is online

Users browsing this forum: No registered users and 19 guest