C# - Coalesce / Tokenize A SQL Command

Mar 1, 2012

I would like to break a "SELECT" SQL statement into its logical components. i.e. I would like to create an object like "SelectSqlStatement" which has a property called "Table", "Where", "OrderBy", etc. The reason I want to do it is that I don't want to manipulate a string but rather manipulate an object and serialize it back to a string. Before I write one for .NET, I was wondering if there was one available. I did a search but didn't see anything.

View 4 Replies


ADVERTISEMENT

Coalesce The Value Using IIf?

Sep 14, 2011

I'm experiencing unpredicted effects with nullables in VB.net. The object in question has a property defined: Public Property Value As Int32?

When I try to coalesce the value using IIf, I get a null exception

cmd.Parameters.AddWithValue("@HOValue", IIf(headOffice.Value.HasValue, headOffice.Value .Value, DBNull.Value))

In C#, I know there's no implicit conversion for nullables, hence you can't use ??, but why is the first part of the IIf being evaluated in VB.NET?

View 3 Replies

C# - Null Coalesce Operator In .Net(8)?

Jan 4, 2011

i'm afraid that this is a stupid question, but i must assume that i have programmed VB.Net too long and now can't figure out how to convert this C# null coalescing operator into VB.Net:

if( Convert.ToBoolean(ViewState[tp.UniqueID + "_Display"] ?? true) == false ){}

I know the IIF-Function but i'm not sure how to use it here and if it gives the correct result(in IIF both expressions are being evaluated). Please help to shed light on the dark.EDIT: if you want to see the source of this: forums.asp.net There you can see a solution that generates a Option Strict On disallows implicit conversions from 'Object' to 'Boolean' compiler exception.

View 7 Replies

Chain A Null Coalesce Operator?

Oct 25, 2011

I have a class Customer which contains the property Extensions which in turn contains the property Any. I tried to do: Dim room = If(customer.Extensions.Any.ElementAt(0).InnerText, Nothing) but it threw an error when it did not find an Extension element in the incoming xml. I thought it would return nothing once it saw that the first expression was Nothing. Do I have to do a multiple if statement in this case?

View 1 Replies

Use Coalesce With Db Column Values And Nullable Types?

Dec 8, 2011

I'm trying to do something similar to what's described here, but with nullable types.

[URL]

int availableUnits = unitsInStock ?? 0;

In VB, it would be this:

Dim availableUnits As Int32 = If(unitsInStock, 0)

However I'm working with db columns, which could be DbNull, and nullable types, which can be Nothing (which is different to DbNull). If a column is DbNull, I want to return Nothing, otherwise return the value. For eg:

Dim availableUnits As Int32? = If(myDataReader("UnitsInStock").Value, Nothing)

The error I'm getting is "Specified cast is not valid" but I'm not sure why. I've tried this as well:

Dim availableUnits As Int32? = If(isDbNull(myDataReader("UnitsInStock").Value), myDataReader("UnitsInStock").Value, Nothing)

Which is messy and just results in the same error. The only thing that works is this:

Dim availableUnits As Int32?
If isDbNull(myDataReader("UnitsInStock").Value) Then
availableUnits = myDataReader("UnitsInStock").Value
Else
availableUnits = Nothing
End If

Which is just silly. Is there a better way of getting nullable db values into nullable variables that I'm not aware of?

View 3 Replies

VS 2010 How To Tokenize In VB 2010 Express

May 17, 2012

I have database table having values like:

col1 has some value.
col2 has some value
col3 has some value

[code].....

How can I show values from col4 on my form, maybe in grid. I know it have to be tokenized,but considering that I'm new, do you have some guide or idea how to do it?

View 4 Replies

Linq To Sqlite - This Returns The Error "Coalesce Used With Type That Cannot Be Null"?

Sep 17, 2010

I am using vb.net sqlite.net and dblinq0.20.1 to search a sqlite table on a primary key field.My code looks like this

Dim blb = (From d In db.Data Where d.UID = myuid Select d).Single

This returns the error "Coalesce used with type that cannot be null" .If I search on a nullable field it works fine.

View 1 Replies

Send A Command To A Command Line And Then Submit The Command?

Apr 30, 2010

First let me say that I am not sure whether or not this should go in this section or the API section, and if it needs to be moved I apologize. My issue is fairly straight forward, but for some reason I cannot get it to work.

I am trying to send a command to a command line and then submit the command. I have been trying without success to get this to work in v2008 Express and v2010 Express, Here is the code I am trying to us:

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String _

[Code].....

View 6 Replies

Coalesce Operator And Conditional Operator In .NET?

Mar 10, 2009

Possible Duplicate: Is there a conditional ternary operator in VB.NET?

Can we use Coalesce operator(??) and conditional ternary operator(:) in VB.NET as in C#?

View 5 Replies

Using Psexec.exe From PsTools To Send A Command To A Remote System To Fire A Command

Mar 17, 2010

I am currently using psexec.exe from PsTools to send a command to a remote system to fire a command through a command prompt however I am finding that the shell I am doing does not seem to like the spaces in the path.

[Code]...

View 3 Replies

ExecuteReader Requires Command To Have Transaction When Connection Assigned To Command Is In Pending Local Trans?

Nov 8, 2007

Any ideas on how I handle the following error thrown in the SqlDataAdapter.Fill as a result of the BeginTrans in the callee?

System.InvalidOperationException = {"ExecuteReader requires the command to have a transaction when the connection assigned to the command is in a pending local transaction.The Transaction property of the command has not been initialized."}

[code].....

View 7 Replies

IDE :: ExecuteReader Requires Command To Have Transaction When Connection Assigned To Command Is In Pending Local Trans?

Jun 30, 2010

Public Sub ExecuteTransaction(ByVal connectionString As String) Using connection As New OleDbConnection(connectionString)

Dim command
As New OleDbCommand()
Dim transaction
As OleDbTransaction

[Code]...

View 1 Replies

Command Line Switches - Keeping Command Window Open?

Feb 24, 2010

I am using the following code to run defrag and to analyze if the C: drive requires defragmentation:

Dim analyze As Process = System.Diagnostics.Process.Start("C:WindowsSystem32defrag.exe", "C: /a /h /u /v")

This process runs through analyzing, runs it in normal mode & prints the progress to the command window.

My problem is that as soon as the process is complete the command window closes. I need it to stay open so that I can read the results.

View 3 Replies

Send Command To Command Line From Windows Form Application?

Mar 11, 2010

I am trying to send a command to the external command line (cmd.exe) from the Windows form application that I'm writing in VB.NET (using VS2008).

I can only access the external program thru the command line (its not my program) and I must do so from a form app.

I am trying to use the following code. I am able to call a cmd.exe window, but I can't pass the command line my command.

Using mp As New Process
With mp.StartInfo
.FileName = "cmd.exe"

[Code].....

View 8 Replies

Add New Sql Command To DataSet's Command Collection And Fill DataTable?

Jan 16, 2010

I want to add a new select command to my dataset. To do that, I have added a new partial class to my project. Because we have to use partial class if we want to extend generated dataset codes. [code]...

View 3 Replies

Command Line Program To End Before Moving Onto The Next Command In Loop?

Feb 4, 2011

I am using a CheckedListBox that is populated with Filenames (full path, i.e. C:TestTest.jpg)When I have the files that I want in the CheckedListBox I wish to click a Start Button which will process the list one at a time using an exe program that runs on the Command Line. There are arguments that need to pass to the command line as well as the file location in order for the program to process.I currently have it working but the issue is the loop finishes quickly and it is left up to the CMD.exe to finish the process. What I would like is for the LOOP to wait until each file completes processing before passing the command for the next file in the CheckedListBox.There some reasons I wish for it to work this way.

1) I would like to have a button that can Pause/Restart the Loop.

2) I would like to have a button that can Stop the Loop so the whole process can end.

3) I would like to have the Loop remove each file one by one from the CheckedListBox after it has been processed.

4) I would like to display a Message once all the files have been processed.

5) And if it were possible I would like to report the status either by text or a progress bar showing where it is at in the process.

6) And the ability to add some error handling if possible.

Since the Loop finishes so quickly as it just passes the command to the command line using the & as a seperator it is the command line that is handling the rest of the process. Because of this there is not control over it in the GUI.The code I am using allows the Command Line text to display in the Form so it won't open up a seperate window to run CMD.exe. This is the desired affect as I would like everything to appear to run from within the Form itself.

[Code]...

View 6 Replies

Insert Command Not Functional After Clear Command In Vb Report

Aug 21, 2011

User need to select their prefferable data to show in report. What i did is i have a clear command first to delete the temporary table. The temporary table is basically a table to stored user selection parameter data. After the clear command, i have
a insert command to insert user selection data into the temporary table. What happened now is when i run the program exe, first run of the report is work fined, but not the second and the following times of execution. It will return null or blank report. The weird thing is when i execute it from development environment, it seem like the report is able to pick up user selection parameter and run the report for the first times and the subsequent execution.

View 3 Replies

Preset A Command And Have The Command Called On Different Option Clicks?

May 18, 2009

i have seen this in many codes, just not sure where to start and how to call the command. what i'm talking about is having code as such (this is for save file dialog):

[Code]...

View 3 Replies

Command Prompt 'Copy' Command Equivalent

Apr 24, 2011

In the Windows Shell, there is a command that looks like this: copy /b fileA.zip + fileB.jpg fileC.jpg..Is there any equivalent function in VB.NET? I already know this works: [code] But I would much rather have a built-in function to work with. Here is what I am trying to do: url...Also, this doesn't just work for pictures. It works for any binary file. Is there any way in VB.NET to tell if a file is binary or text?

View 3 Replies

Hide Characters In SET Command On Command Prompt?

Feb 6, 2011

Is there a way to hide the characters of a "set /p password=Enter Password:" command? Or any new strand not using the SET command i could use instead?

View 2 Replies

.NET - Pass Command On Command Line?

May 29, 2012

I am struggling to pass a parameter to a VB.NET application via a Windows scheduled task. It works perfectly in Visual Studio (passing a command line arguement via project properties).If I am calling a VB6 application, then I will supply the following parameters and it works:

Run: c:progra~1TestTest.exe TestParameter Start In: c:progra~1Test However, if I supply the same parameters in VB.NET, the program throws an exception when it tries to create an instance of a class in the Form.Load: System.NullReferenceException cannot create instance of object.

I have also tried the following:Run: c:program filesTestTest.exe TestParameter Start In: "c:program filesTest" This time the status of the scheduled task changes to "cannot start".What is the correct way to specify command line parameters in a scheduled task for a VB.NET program?UPDATE I found the solution on this web page:[URL}.. I am still confused as to why the program would not create an instance of an object when I used the 8 bit paths (i.e. progra~1)

View 1 Replies

Command Text Was Not Set For Command Object

Apr 23, 2011

I'm running into the following error message when I click the button event: Command text was not set for the command object. [code]

View 1 Replies

Command Text Was Not Set For The Command Object

Dec 21, 2009

If I comment out MdiUpdate() this run fine. When I run it with MdiUpdate I get the following Error...

da.Fill(ds,
"Mdi") Command text was not set for the command object.

I have also taken the code from the select statement and put it into the other 2 (replace the CliendGroupID = 3) and it works fine
Here is the code:

Public
Class NewFileInput
Dim inc As Integer

[code]....

View 2 Replies

Command Line Argument: Check If Correct Command Line Or Exit App?

Jun 6, 2012

I have beginner skills using VB (am using the Express edition to learn). I would like to know how to set up a conditional statement in a Windows Form (WF) app that would check if a specific command line has been passed by another separate app that launchesthe Windows Form app using command lines, and if not passed, then the Windows Form app would shut down (exit, close).So far, I can use:

For Each s As String In My.Application.CommandLineArgs
If s <> "xyz" Then
Me.Close()

[code]....

View 14 Replies

Command Prompt "Copy" Command Equivalent?

Feb 10, 2012

In the Windows Shell, there is a command that looks like this:copy /b fileA.zip + fileB.jpg fileC.jpgIs there any equivalent function in VB.NET? I already know this works:Shell("cmd copy /b fileA.zip + fileB.jpg fileC.jpg")

View 5 Replies

Open Command Prompt And Run The Command "netstat -a"

Oct 2, 2011

I'm starting to make a program that will run some commands, so i need some code that will open command prompt and run the command "netstat -a".

View 11 Replies

C# - .NET Equivalent Of The Command Prompt "where" Command?

Nov 8, 2011

In .NET, is there an equivalent of the "where" command that is present on Windows Vista and Windows 7 machines? I need to resolve the hard path to an executable that is defined in the system path at install time, and not everyone installs everything using the default installation path.

Currently I call the "where" command as an external process, but this only works on Vista and Windows 7 machines, this does not work on XP out of the box.

View 3 Replies

Command To Go To A Different Sub

Feb 12, 2011

Is there a command there let's you go to a different sub as if it were separately activated? if so, what is it?

View 2 Replies

Get The Value Of A Sql Command?

Sep 20, 2010

I need to get the value of a sqlcommand. for instance: I use this :

Dim
str
As
String

[Code].....

View 2 Replies

How To Do A Dos Command

Oct 11, 2009

how to do a dos command in Visual Basic 2008?Maybe for example: shutdown a pc in your lan. It's with shutdown -s -m \PC_RYDER like this but in Visual Basic.

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved