|
I am trying to empty partnumber columns in sql database that have all zeroes so that the column will be blank. I am writing code through vb.net. Here is some code that I am using but it doesn't work:
Function:
Public Function Empty(ByVal supercedeto As String) As Boolean
Dim number As String
number = String.Empty(supercedeto)
End Function
Code:
If row("mostforwardpartnumber").ToString() = "0000000000000" Then
Empty(row("mostforwardpartnumber"))
End If
jds1207
|
|
|
|
|
Hi,
The function as you posted it here, does not return anything, nor does it affect anything outside itself.
jds1207 wrote: Public Function Empty(ByVal supercedeto As String) As Boolean
Dim number As String
number = String.Empty(supercedeto)
End Function
Does the column contain a set or random amount of zeroes?
jds1207 wrote: If row("mostforwardpartnumber").ToString() = "0000000000000" Then
Empty(row("mostforwardpartnumber"))
End If
If the amount of zeroes is always the same, you don't need a function to empty the row. Try something like this:
<br />
Dim EmptyNr as integer<br />
Dim rw as datarow<br />
For Each rw In YourDataSet.Tables(0).rows<br />
If rw.item("mostforwardpartnumber") = "0000000000000" Then<br />
rw.item("mostforwardpartnumber") = EmptyNr<br />
End If
Otherwise you'll need to write a function that checks the value of the column and based on what that function returns, you can then empty the cel.
Hope this helps you,
Johan
|
|
|
|
|
being new to VB.NET, how do you programmatically select a datagrid cell
silver-gray
|
|
|
|
|
Give This a try
<br />
Datagrid1.CurrentCell = new Windows.Forms.DatagridCell(row, col)<br />
Kevin
|
|
|
|
|
what I'm trying to do is programmatically select all cells in the 4th column that comtain nulls, and change the backcolor to red. I have vb.net 2003.
silver-gray
|
|
|
|
|
how to well write the below statement :
I got into the msgbox(ii) even the value of the called function
[getavailableswitch(checkStr)] is 0
Dim ii As Integer <br />
If ii = getavailableswitch(checkStr) <> 0 Then<br />
MsgBox(ii)<br />
End If
Note : i want the the following to be done within the same if
1-call the function
2-test the retrieved data from the function
Am i thinking correctly???
Regards
Ramy
|
|
|
|
|
i found that this statement goes right
ElseIf (i = getavailableswitch(checkStr)) And i <> 0 Then<br />
MsgBox(i)<br />
End If
i got my respone
thx anyway :
but is there any other way of thinkin?
Regards
Ramy
|
|
|
|
|
What type value does your function return?
Your function should return as an integer or else you would need to convert to an integer to test the return value
i.e.
function getavailableswitch(checkstr as string) as integer
return 1
end function
If Not getavailableswitch(checkStr) = 0 then
or
If getavailableswitch(checkStr) <> 0 then
or
if CInt(getavailableswitch(Checkstr)) <> 0 then
Moo
|
|
|
|
|
this is function that i m using and it returns an integer
Public Function getavailableswitch(ByVal checkstr As String) As Int16<br />
....<br />
getavailableswitch = cmd.ExecuteScalar()<br />
end function
what i want is: to call the above function and
thus
Dim id As Integer<br />
If id = getavailableswitch(checkStr) <> 0 Then<br />
MsgBox(id)<br />
End If
i know it sounds very bad,
Note i want to do withing the "if" statement
1-the call statement
2-the test on retreived data from the function
thx for your help
Regards
Ramy
|
|
|
|
|
i want to use dataset with created runtime to populate my report.i use this code
Classes_Obj.getRecord is return dataset
but this gives error as "The report has no tables"
could anyone help me
Dim aa As DataSet
aa = Classes_Obj.getRecord("select * from Frames")
ReportPurchase.SetDataSource(aa)
ReportViwer.rptContainer.ReportSource = ReportPurchase
'ReportPurchase.PrintToPrinter(1, False, 0, 0)
ReportViwer.ShowDialog()
-- modified at 9:08 Monday 27th November, 2006
|
|
|
|
|
Hi, The following code is generating an error....I have put comments in front of the line that generated error.
Can anybody help me in this?
Thanks,
Public Sub ConnectSQL()
Dim conn As New SqlClient.SqlConnection
Dim da As New SqlClient.SqlDataAdapter
da = SqlDataAdapter1 'This Adapter is manually created using the Wizard
conn = SqlConnection1 'This Connection is manually created using the Wizard
Dim selectCommand As New SqlClient.SqlCommand("SELECT cFName from PersonalDetails") 'Selecting The first column from the table
da.SelectCommand = selectCommand
Dim Reader As SqlClient.SqlDataReader
Dim RecordCount As Integer = 0
conn.Open()
Reader = selectCommand.ExecuteReader() 'This line is generating an error!!
Dim Records As String
While Reader.Read()
Dim i As Integer = 0
For i = 0 To Reader.FieldCount - 1
Records &= Reader(i) & "-"
Next
RecordCount += 1
End While
|
|
|
|
|
The Problem is you are not setting the connection or command type of your select command. Add these two lines right before you execure the reader
<br />
selectCommand.Connection = conn<br />
selectCommand.CommandText = CommandType.Text<br />
Hope this works
Kevin
|
|
|
|
|
Hi Kevin
I added the above lines of code. I am getting the same error.
However, Thanks for your help
|
|
|
|
|
Private Sub btnButtonvisible_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnButtonvisible.MouseEnter
btnButtonvisible.Visible = False
End Sub
Private Sub btnButtonvisible_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnButtonvisible.MouseLeave
btnButtonvisible.Visible = True
End Sub
End Class
shyamy
|
|
|
|
|
And your question is?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi All,
One help.
I have the below function declaration.What is the default access specifier of the declaration.Is it private or public.
"Function FindDevice() As Boolean"
|
|
|
|
|
The default is Public . You can find out more here[^].
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
|
i m a student . and i want to make a software in asp.net.....
i want a simple topic which i can handel;P;P
hdfh
|
|
|
|
|
Well, we have no idea what you can handle. Have you done any study ? Read any books ?
Do you know how to work with a database ? If so, how about a CD list web app ? That's nice and simple.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
This[^] was designed especially for you
|
|
|
|
|
I like it!
Kevin
|
|
|
|
|
A guestbook is a good beginner project. It contains the simplest form of the basic principles for most web applications; data entry, storage and retrieval.
---
b { font-weight: normal; }
|
|
|
|
|
Dear All,
I want to fire message box while my one function is running and after clicking yes on message dialoge, i want to process another code in VB.Net.
is their any technique that i can use to do so other than javascript...because javascript allows me to fire confirmation box on click event of button or any control.. i want my message box fired in between code running...
Urgent Help Needed....
Thanks,
TC
|
|
|
|
|
Hi TC,
Your problem description is a bit vague. Do you just need confirmation from the user before the process can continue, or do you want to run two processes at the same time, one of which should ask for confirmation while the other one just continues?
Regards,
Johan
|
|
|
|