Quantcast
Channel: Visual Studio and Visual Web Developer Express
Viewing all articles
Browse latest Browse all 3509

If Not String.IsNullOrEmpty

$
0
0

I have a WebPage with VB.NET - I have an inventory system that if a part number is not showing in a textbox (example textbox45.text) then it skips the command
and goes to the next one (textbox51.text). I have tried a couple of commands
'If Not String.IsNullOrEmpty(TextBox45.Text) Then
or
'If TextBox45.Text = True then

It returns an error @TransactionName - However, when I check the SQL data table, it did add only the data with text
in the textbox(s) and skipped the blank one(s) as I wanted to do. But can't get past the error.

Any help would be great! thanks.

cmd.Parameters.Clear()
'If Not String.IsNullOrEmpty(TextBox45.Text) Then
'If TextBox45.Text = True then

cmd.CommandType = CommandType.Text
With cmd.Parameters
.AddWithValue("@TransactionName", "Consumed")
.AddWithValue("@TransactionDate", TextBox2.Text)
.AddWithValue("@PurchaseOrder", TextBox8.Text)
.AddWithValue("@UnitsSold", "-1")
.AddWithValue("@Date", TextBox2.Text)
.AddWithValue("@StationID", TextBox1.Text)
.AddWithValue("@WhseID", TextBox4.Text)
.AddWithValue("@WipLocation", DropDownList1.Text)
.AddWithValue("@InvName", TextBox45.Text)
End With
'End If

cmd.Connection = cn
cn.Open()

cmd.ExecuteNonQuery()

cn.Close()

cmd.Parameters.Clear()
'If Not String.IsNullOrEmpty(TextBox51.Text) Then
'If TextBox51.Text = True Then
cmd.CommandType = CommandType.Text
With cmd.Parameters
.AddWithValue("@TransactionName", "Consumed")
.AddWithValue("@TransactionDate", TextBox2.Text)
.AddWithValue("@PurchaseOrder", TextBox8.Text)
.AddWithValue("@UnitsSold", "-1")
.AddWithValue("@Date", TextBox2.Text)
.AddWithValue("@StationID", TextBox1.Text)
.AddWithValue("@WhseID", TextBox4.Text)
.AddWithValue("@WipLocation", DropDownList1.Text)
.AddWithValue("@InvName", TextBox51.Text)
End With
'End If

cmd.Connection = cn
cn.Open()

cmd.ExecuteNonQuery()

cn.Close()


Viewing all articles
Browse latest Browse all 3509

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>