|
Why does your SP return 0 ? If you call the stored procedure, you'll get back a dataset, you can then grab the one table in that data set and make it the datasource on a DataGrid. That's all you need to do to get a basic display of your data.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
what should the SP return instead of "0"?
|
|
|
|
|
Nothing, why does it matter ? It returns the tables, the scalar does not matter most of the time.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Please, talk to me about:
How do you get list of machines in LAN by VB.NET?
Thanks very muchs.
Phuoc Tuyen
|
|
|
|
|
|
Depends on what you want to achieve, but I have used this VB.NET code to query Active Directory. You will need to modify it for your purposes. Lookup the help on the objects shown here for examples of what they can provide.
Imports System.DirectoryServices
Private Sub ScanMachines()
'
' Get the list of machine names in the current domain
' as specified by txtMachineSpec.
'
Dim ds As New DirectorySearcher
ds.SearchRoot = New DirectoryEntry
Dim wildcards() As String = Split(txtMachineSpec.Text.ToUpper, ",")
ds.Filter = GetFilterString(wildcards)
ds.PropertyNamesOnly = True
ds.PropertiesToLoad.Add("name")
ds.Sort = New SortOption("name", SortDirection.Ascending)
ds.PageSize = 9999
Dim src As SearchResultCollection
Try
'
' Enumerate the machines in AD.
'
src = ds.FindAll()
Try
For Each sr As SearchResult In src
'
' Get the machine name, stripping off the "CN=" portion
' as we go.
'
Dim de As DirectoryEntry = sr.GetDirectoryEntry()
Dim machineName As String = Replace(de.Name, "CN=", "", 1, 1)
'
' Do your stuff here ...
'
Next
Catch ex As Exception
MessageBox.Show("1: " & ex.Message)
End Try
Catch ex As InvalidOperationException
MessageBox.Show("2: " & ex.Message)
Catch ex As NotSupportedException
MessageBox.Show("3: " & ex.Message)
Catch ex As Exception
MessageBox.Show("4: " & ex.Message)
Finally
If Not src Is Nothing Then
src.Dispose()
End If
If Not ds Is Nothing Then
ds.Dispose()
End If
End Try
End Sub
...Steve
|
|
|
|
|
|
Hi I'm trying to code a calendar control so that I can use this control to show dates (emphasis on several dates) highlighted in the month view of the control.
I am trying an Active X control, MSCAL.Calendar.7, but it may not support what I need to do.
I want to highlight several dates on a Month view of the calendar control, preferably in a color like red or something other than Grey/depressed.
What properties can do this for me and where should I look for examples?
Thanks,
REMOTE USER
|
|
|
|
|
Sorry, this is in Access, using VBA to code it up.
|
|
|
|
|
Hi all.
It might be the late hour but I can't figure out why this little piece of code won't work when I apply it in the real world:
' selectTest should eval to true...<br />
Sub doTest()<br />
selectTest 543<br />
End Sub<br />
<br />
Function selectTest(intAntal%)<br />
Select Case (intAntal)<br />
Case ((30 / 20) * 100), Is >= 100<br />
selectTest= True<br />
Exit Function<br />
Case Else<br />
selectTest= False<br />
End Select<br />
End Function
While this work, the equaling real code won't:
With objStation.Parkeringer(intP).Taellinger(intT)<br />
Select Case (.intAntalPladser)<br />
Case 0<br />
SkalMed = True<br />
If .intAntalParkeret = 0 Then<br />
MsgBox "På " & objStation.strNavn & " er der en tælling med" & _<br />
" 0 P-pladser og 0 parkeret." & Chr(10) & _<br />
"Stationen kommer med i rapporten.", vbInformation, "Advarsel"<br />
End If<br />
Exit Function<br />
Case ((.intAntalParkeret / .intAntalPladser) * 100), Is >= intBelaegningsprocent<br />
SkalMed = True<br />
Exit Function<br />
Case 1345, Is > 90 ' the code should at least stop here... but doesn't<br />
Stop<br />
Case Else<br />
SkalMed = False<br />
End Select<br />
End With
The above select case (almost) always returns false. It seems like it works sometimes. Like when intBelaegningsprocent is set to 5 but not 80 or 90.
Any ideas on why this happens?!?
Regards Jon.
Moving to C# .NET - the grass is always greener..
|
|
|
|
|
Jon,
There are many implicit data type conversions in this code (i.e. double to integer, float etc...). Maybe the erratic behaviour of the Select is caused by this?
My advice is to strictly type each variable and function to ensure that you are comparing similar data types rather than letting the compiler make its best guess at it.
e.g.
<br />
Option Strict On<br />
<br />
Function selectTest(ByVal intAntal As Integer) As Boolean<br />
<br />
Select Case (intAntal)<br />
<br />
Case CInt((30 / 20) * 100), Is >= 100<br />
selectTest = True<br />
'Exit Function<br />
<br />
Case Else<br />
selectTest = False<br />
<br />
End Select<br />
<br />
End Function<br />
Maybe the code in your second example is not stopping at Case 1345, Is > 90 is perhaps the case variable .intAntalPladser is neither 1345 nor > 90; or an exception is being thrown here or in preceeding Case statements. To investigate this, wrap the code in a a Try..Catch block to trap and display any errors.
...Steve
|
|
|
|
|
Thanks Steve for your reply. I figured it out. I was trying to use the select case statement as an If..ElseIf statement. Obviously I couldn't. Oh I forgot to mention that I use VB6 for this project (Access XP).
Moving to C# .NET - the grass is always greener..
|
|
|
|
|
I currently have an array of bytes and I want to print it to a file. When I open the filename and do the following statement:
Print #FileName, ArrayOfBytes
it prints a bunch of question marks and other characters that aren't the correct characters.
When I run the debugger, the values within the individual elements of the array are all the correct decimal ascii values.
ArrayOfBytes(1) = 50 It should be "P", which is what I want printed.
ArrayOfBytes(2) = 88 It should be "X", which is what I want printed.
How do I print this to a file but get the correct character values?
Thank you.
|
|
|
|
|
You need to convert the decimal values back to ascii characters. Here is a code snippet
=Encoding.ASCII.GetString(ArrayOfBytes,0,ArrayOfBytes.Length);
this returns a ascii encoded string
|
|
|
|
|
hello i want to connect to the ftp through vb.net .. i cannot find something suitable for me. i am working with vb.net and i am very confused!! can someone give me a link or some help pls. i want to download and upload a txtfile only! i dont want it for nothing else. i want to make a small messanger thats it. thanks!!
|
|
|
|
|
|
Is there a way to use a dll that was created in vb.net by vba?
|
|
|
|
|
So long as your VB.NET DLL is properly exposed to COM and registered, then it should work just like any other component. VB.NET and C# don't export functions like you would find in a unmanaged code DLL.
You can find out more by searching the articles for "expose COM", or click here[^].
|
|
|
|
|
|
I have a simple syntax issue that is causing me grief. In one of my dropdowns, several of my users have used "&" or " ' " in their choices. eg. Pete's Meat & Grocery. In VBA, the solution would be simple, I would imploy use the following syntax to convert the entire response to a string:
'" & NameofField & "' or if the field was numeric " & NameofField & "
In VB.net, this does not work. The function that I am running halts on Pete's Meat & Grocery and states that it cannot interpret the ' or the &.
What syntax do I use so that the entire contents of the field are read as one regardless of whether any of the contents are reserve keys or wildcard characters.
Thanks
Pat
|
|
|
|
|
There's something you're not telling us. Just putting an '&' character in a String will not screw up your code. Is this going to a database or something? A code snippet of where the problem is occuring would help greatly!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
This is part of an automatic 'save' function that I have developed. Here is a code snippet.
EditALLFields(Me.txtPaymentCounter.Text, cboPayableTo.SelectedValue, "tb_Payments", "PayableTo", "Counter", "String")
Where...
EditALLFields = Name of Function
Me.txtPaymentCounter.Text = Unique Row ID Number for Source Table (tb_Payments)
Me.cboPayableTo.Text = Value of Combo or Text Box
tb_Payments = Source Table
Counter = Unique ID Field of Source Table (tb_Payments)
String = DataType of Field that is to be saved (Me.cboPayableTo) (Could be string, numeric, or date)
Now... if the value of Me.cboPayableTo.text does not include a wildcard, reserved character, or " or ' then, the function properly saves the value in Me.cboPayableTo back to tb_Payments. Works perfectly.
However, in the example that I used: Pete's Meat & Grocery... we have two parts that halt the function. Both the ' and the & halt the function with an error message:
Incorrect syntax near 's'. Unclosed quotation mark before the character string.
I won't bore you with the syntax of the actual EditALLFields function, but if necessary, I can. It is actually very concise and tight. The EditALLFields function merely opens the data connection, identifies the correct table, record, and parameters and saves the record. I have developed this because my users have a severe distain to any 'Save' Button on the actual form. So instead, I simply run this function on the 'Leave' event for each field. It sounds like alot of overhead, but in actuality, it is very quick, simple and extremely convenient for my users.
Pat
|
|
|
|
|
Capilano wrote:
I won't bore you with the syntax of the actual EditALLFields function, but if necessary, I can.
This is EXACTLY what we need!
|
|
|
|
|
Here is the Function:
Public Function EditALLFields(ByVal sID As String, ByVal sValue As String, ByVal sTable As String, ByVal sField As String, ByVal sIDField As String, ByVal sType As String)
Dim cmdSaveCurrentField As SqlCommand = New SqlCommand
Try
If CN.State = ConnectionState.Open Then
Else
CN.Open()
End If
With cmdSaveCurrentField
.Parameters.Clear()
.Connection = CN
.CommandText = "SaveFields"
.CommandType = CommandType.StoredProcedure
'Matches up to value of ID field at very beginning of row
.Parameters.Add("@sID", SqlDbType.VarChar, 255).Value = sID
'Is the new data value entered
.Parameters.Add("@sValue", SqlDbType.VarChar, 4000).Value = sValue
'Name of Table you are updating
.Parameters.Add("@sTable", SqlDbType.VarChar, 255).Value = sTable
'Name Field you are updating
.Parameters.Add("@sField", SqlDbType.VarChar, 255).Value = sField
'name of IDField for the Table
.Parameters.Add("@IDField", SqlDbType.VarChar, 255).Value = sIDField
'Type is data type
.Parameters.Add("@sType", SqlDbType.VarChar, 255).Value = sType
.ExecuteNonQuery()
End With
Catch ex As Exception
MsgBox(ex.Message)
Finally
cmdSaveCurrentField = Nothing
If CN.State = ConnectionState.Open Then
CN.Close()
End If
End Try
End Function
|
|
|
|
|
With what you've described and what you posted as your code, it's not this code that breaking. Instead, it would appear that it's your stored procedure, SaveFields, that's breaking.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|