cmd.ExecuteNonQuery() return no integer - visual-studio-2010

In my visual studio 2010, vb.net
Dim rowsAffect As Integer
sql = "Update temptable Set Exp_Amt=0 Where Exp_Amt is Null"
cmd.CommandText = sql
rowsAffect = cmd.ExecuteNonQuery()
When I debug this by use F10 key , rowsAffect = &HD .
Actually , rowsAffect value should be number 1 or 2 or something like that.
Is it need to change setting in VS 2010 IDE ?

To change how numbers are shown in the Watch, Locals, or Autos Window1, whilst debugging, you should right-click within the grid and tick (for hex) or untick (for decimal) the Hexadecimal Display option.
1Possibly others also, you haven't said where you're seeing this value, but those are the most obvious ones.

Related

IIf function doesn't work (Visual Studio 2013 BI Tools)

I'm using Visual Studio 2013 (with SQL-Server 2014, Reporting Services and BI Tools) and I try to add an simple "iif" expression but the compiler returns an Error (value = -1073741511)
I tried:
= IIf ( 3000 > 1000, "True", "False" )
Is it possible that the compiler doesn't support these kind of expression or are there similar ones?
What I need is an expression to get a value from my db where the id = x
= IIf ( Fields!ID.Value = 1 , Fields!Value.Value, 0 )
It was a problem with the compiler itself
See this post for more infos: Visual Basic Command Line Compiler has stopped working
anyway thanks!

How can I set a mask to field of database on crystal report (visual studio 2008)

I try to set a mask if the string have less characters.
Like this:
expected = 00000001
real= 001
Really I used this code and worked it!
ReplicateString ("0",8-Length(cstr(ToNumber({SAGFacturaSOP.NumFactura}),0))) + cstr(ToNumber({SAGFacturaSOP.NumFactura}),0)

VB6, Adding an integer to a control name in a for loop

I am currently trying you learn VB6 and came across this issue.
I wanted to loop through a for loop and adding a number to a control name.
Dim I As Integer
For I = 1 To 5
S = CStr(I)
If TextS.Text = "" Then
LabelS.ForeColor = &HFF&
Else
LabelS.ForeColor = &H80000012
End If
Next I
This S needs to be added to Text and Label so the colour will be changed without needing to use 5 If Else statements
I hope you can help me with this.
From your comment below:
What i mean is this: If Text1.text = "" Then I need this 1 to be replaced with the variable I, so the for loop can loop through my 5 textboxes and the same for my Labels.
You can't do that (look up a variable using an expression to create its name) in VB6. (Edit: While that statement is true, it's not true that you can't look up form controls using a name from an expression. See "alternative" below.)
What you can do is make an array of your textboxes, and then index into that array. The dev env even helps you do that: Open your form in the dev env and click the first textbox. Change its name to the name you want the array to have (perhaps TextBoxes). Then click the next textbox and change its name to the same thing (TextBoxes). The dev env will ask you:
(Don't ask me why I have a VM lying around with VB6 on it...)
Click Yes, and then you can rename your other textboxes TextBoxes to add them to the array. Then do the same for your labels.
Then your code should look like this:
For I = TextBoxes.LBound To TextBoxes.UBound
If TextBoxes(I).Text = "" Then
Labels(I).ForeColor = &HFF&
Else
Labels(I).ForeColor = &H80000012
End If
Next
LBound is the lowest index of the control array, UBound is the highest. (You can't use the standard LBound and Ubound that take the array as an argument, because control arrays aren't quite normal arrays.) Note also that there's no need to put I on the Next line, that hasn't been required since VB4 or VB5. You can, though, if you like being explicit.
Just make sure that you have exactly the same number of TextBoxes as Labels. Alternately, you could create a user control that consisted of a label and a textbox, and then have a control array of your user control.
Alternative: : You can use the Controls array to look up a control using a name resulting from an expression, like this:
For I = 1 To 5
If Me.Controls("Text" & I).Text = "" Then
Me.Controls("Label" & I).ForeColor = &HFF&
Else
Me.Controls("Label" & I).ForeColor = &H80000012
End If
Next
This has the advantage of mapping over to a very similar construct in VB.Net, should you migrate at some point.
Side note:
I am currently trying you learn VB6...
(tl;dr - I'd recommend learning something else instead, VB6 is outdated and the dev env hasn't been supported in years.)
VB6's development environment has been discontinued and unsupported for years (since 2008). The runtime is still (I believe) supported because of the sheer number of apps that use it, although the most recent patch seems to be from 2012. But FWIW, you'd get a better return on your study time learning VB.net or C#.Net (or any of several non-Microsoft languages), rather than VB6...

Parameters for Jump to Report in VS 2010

I have a report in Visual Studio 2010 with two fields that have jump to's. Both jump to the same report. However, one of them only requires 3 parameters to be passed whereas the other field requires 4. How can I keep the same report that is being jumped to for both fields? I can't figure out a way to not have to pass the Date parameter. I know I can create a separate dataset and a separate report, but I'd like to avoid that if possible.
SELECT SalesData.SBLOC, SalesData.SBCUST, SalesData.RMNAME, SalesData.SBITEM, SalesData.IFPRVN, SalesData.SBITD1, SalesData.SBDIV, SalesData.SBCLS,
SalesData.SBQSHP, SalesData.AVC, SalesData.SBEPRC, SalesData.SBINV, SalesData.SBORD, SalesData.SBTYPE, SalesData.SBINDT, SalesData.RMSTAT
FROM SalesData INNER JOIN
FiscalCalendar ON SalesData.SBINDT = FiscalCalendar.FiscalDate
WHERE (FiscalCalendar.FiscalYear = '2013') AND (SalesData.SBLOC IN (#Location)) AND (SalesData.SBTYPE = 'O') AND (FiscalCalendar.FiscalMonthName IN (#FiscalMonthName)) AND (FiscalCalendar.FiscalWeekNum IN (#FiscalWeekNum)) AND (FiscalCalendar.FiscalDate IN (#FiscalDate))

Remove a keyboard shortcut binding in Visual Studio using Macros

I have a lot of custom keyboard shortcuts set up. To avoid having to set them up every time I install a new visual studio (happens quite a lot currectly, with VS2010 being in beta/RC) I have created a macro, that sets up all my custom commands, like this:
DTE.Commands.Item("ReSharper.ReSharper_UnitTest_RunSolution").Bindings = "Global::Ctrl+T, Ctrl+A"
My main problem is that Ctrl+T is set up to map to the transpose char command by default. So I want to remove that default value in my macro.
I have tried the following two lines, but both throw an exception
DTE.Commands.Item("Edit.CharTranspose").Bindings = ""
DTE.Commands.Item("Edit.CharTranspose").Bindings = Nothing
Although they kind of work, because they actually remove the binding ;) But I would prefer the solution that doesn't throw an exception.
How is that done?
I have coped with the same issue. I use a macro to assign key bindings for a set of align macros.
Dim NewBindings() = {"Global::Alt+="}
DTE.Commands.Item("Macros.Dev.AlignUtils.AlignEquals").Bindings = NewBindings
NewBindings(0) = "Global::Alt+Num -"
DTE.Commands.Item("Macros.Dev.AlignUtils.AlignMinus").Bindings = NewBindings
...
And to remove key bindings i use the following statements :
Dim DelBindings() = {}
DTE.Commands.Item("Macros.Dev.AlignUtils.AlignPlus").Bindings = DelBindings
It works fine under Visual Studio 2005.
I followed a little more pragmatic way (using your example):
DTE.Commands.Item("ReSharper.ReSharper_UnitTest_RunSolution").Bindings = "Global::Ctrl+T"
DTE.Commands.Item("ReSharper.ReSharper_UnitTest_RunSolution").Bindings = "Global::Ctrl+T, Ctrl+A"
With the first assignment Ctrl+T is unassigned from any other function and then becomes unbound with the second assignment.
Works like a charm for me.
You do not need to change it with macro, Just go to
Menu>Tools>Options -- Keyboard and then select what you want to change the shortcut from the dropdown and assignyour desiered short cut

Resources