|
hi everyone,
i have created a hashtable that will create 5 random and unique numbers, and have copied it to an array. i now need to retrieve the stored values from the array to individual labels (label1.Text, labe12.text). your help is appreciated.
here is my code:
Dim hash As New Hashtable
Dim RandNum As Integer
Dim targetArray() As DictionaryEntry
For I As Integer = 1 To 5
Do
RandNum = Convert.ToInt32(Rnd() * 15)
Loop While hash.Contains(RandNum)
hash.Add(RandNum, Nothing)
Next
ReDim targetArray(hash.Count - 1)
hash.CopyTo(targetArray, 0)
label.text = targetArray(1) 'i am getting an error stating i cannot
'convert a dictionary entry to string.
Julian
"New to programming and I am hooked"
|
|
|
|
|
You can get an array of the keys or values by hash.Keys and ( I think ) hash.Values.
As you're using .NET 1.1, you need to call ToString, as the contents of your hashtable is an object.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I have the syntax error in update statement but i not sure where did i code wrong....anyone can help?
DB.Execute "update DONO set NO=" & "'" & dono.Text & "'" & _
",Date= " & "'" & ddate.Text & "'" & _
",Customer=" & "'" & Combo1.Text & "'" & _
",Description =" & "'" & ddes.Text & "'" & _
",Total =" & "'" & temptotal.Caption & "'" & _
",BillTerm=" & "'" & dterm.Text & "'" & _
" where [dono] = " & "'" & userin & "'"
|
|
|
|
|
do not put numeric values in ' '
|
|
|
|
|
all my value was in text...
even the date i try to use without ' ' but still the error exict...
-- modified at 4:42 Tuesday 22nd August, 2006
|
|
|
|
|
Check the data type of the columns in the database and do accordingly
Navi
|
|
|
|
|
i had found my error which is the DATE cause the problem...
anyway to update my DATE field??
not sure wats wrong with it, is it the format or data type problem? in my database it's in DATE.
Date= " & "'" & ddate.Text & "'" & _
|
|
|
|
|
|
I was tring to update the Total amount of the specific bill which user may want to add more item in future.
But when i run my function the value always update the record to my first data ..?? any mistake i have make???
HERE is my coding :
'Userin is the value user enter for the bill no.
If answer = vbYes Then
rs.Edit
DB.Execute "update DOno set Total =" & "'" & temptotal.Caption & "'" & _
" where [dono] = " & "'" & userin & "'"
rs.Fields("Total") = temptotal.Caption
rs.Update
rs.MoveFirst
MsgBox ("Total updated")
|
|
|
|
|
remove db.execute statement
Navin
|
|
|
|
|
i think cannot remove cause it will have compile error
|
|
|
|
|
go forward remove DB.Execute statement
DB.Execute "update DOno set Total =" & "'" & temptotal.Caption & "'" & _
" where [dono] = " & "'" & userin & "'"
Navi
-- modified at 6:01 Tuesday 22nd August, 2006
|
|
|
|
|
after remove nothing was update... if dont use the SQL how the vb know which bill I going to update?
|
|
|
|
|
Actually i want to call oracle function which returns boolean value, from vb.net .
I have one function in oracle which return boolean value..0 or 1.
this function is for adding user to table.
i dont have right to access direct table..so i 've to use add_user(Userid,SoftwareId,Role) function for adding a user from vb.net using Oracleclient.
can anybody help me ..?
Thanks
Hemaxi
|
|
|
|
|
The same way as any other database, just use the specific provider classes for Oracle.
You get a connection to oracle (OracleConnection?). You create a command (OracleCommand) and you give it the details of the SQL you want to run and any parameters and the connection you opened earlier. Then you call ExecuteScalar() to get your value back.
|
|
|
|
|
it gives me an error that wrong type of arguments.
If you can help me on this ..will paste my code. and the function from oracle.
Thanks..
hemaxi
|
|
|
|
|
hemrk wrote: it gives me an error that wrong type of arguments.
What is the "wrong type of arguments"?
|
|
|
|
|
check the datatype of the arguments which ur passing.
Navin
|
|
|
|
|
Hey
I think som that datatype is the problematic as my stored procedure returns Boolean Datatype.
and cmd.parameters.add ("",Oracledatatype....doesnt have boolean type.
I m using oracleclient . So , Probably it doesnt support Boolean data type.
Below is my stored procedure parameters..
PROCEDURE Add_User_Role
( UserID IN NUMBER
, SoftwareID IN NUMBER
, RoleNo IN NUMBER
, ReturnValue OUT BOOLEAN);
my vb code is like this...
With cmdUserRoleFunc
.Transaction = myTrans
.Connection = cnContract
.CommandType = CommandType.StoredProcedure
.CommandText = "Add_User_Role"
End With
Dim paramReturnValue As New OracleParameter()
paramReturnValue.ParameterName = "@return_value"
paramReturnValue.OracleType = OracleType.Int32 ' here want to use boolean but doesnt have in enumeration.
paramReturnValue.Direction = ParameterDirection.Output
Dim paramUserId As New OracleParameter()
paramUserId.ParameterName = "@UserId"
paramUserId.OracleType = OracleType.Int32
paramUserId.Direction = ParameterDirection.Input
paramUserId.Value = UserId
Dim paramSftwrId As New OracleParameter()
paramSftwrId.ParameterName = "@SoftwareId"
paramSftwrId.OracleType = OracleType.Int32
paramSftwrId.Direction = ParameterDirection.Input
paramSftwrId.Value = 42
Dim paramRoleNo As New OracleParameter()
paramRoleNo.ParameterName = "@RoleNo"
paramRoleNo.OracleType = OracleType.Int32
paramRoleNo.Direction = ParameterDirection.Input
paramRoleNo.Value = RoleNo
'cmdUserRoleFunc.Parameters.Add(paramReturnValue)
cmdUserRoleFunc.Parameters.Add(paramUserId)
cmdUserRoleFunc.Parameters.Add(paramSftwrId)
cmdUserRoleFunc.Parameters.Add(paramRoleNo)
cmdUserRoleFunc.Parameters.Add(paramReturnValue)
cnContract.Open()
cmdUserRoleFunc.ExecuteScalar() 'Gives me error here..that illegal variable
Pls. Help me..i just wanted to get rid of this problem
Thanks anyways,
Hemxi
|
|
|
|
|
Hey
I think som that datatype is the problematic as my stored procedure returns Boolean Datatype.
and cmd.parameters.add ("",Oracledatatype....doesnt have boolean type.
I m using oracleclient . So , Probably it doesnt support Boolean data type.
Below is my stored procedure parameters..
PROCEDURE Add_User_Role
( UserID IN NUMBER
, SoftwareID IN NUMBER
, RoleNo IN NUMBER
, ReturnValue OUT BOOLEAN);
my vb code is like this...
With cmdUserRoleFunc
.Transaction = myTrans
.Connection = cnContract
.CommandType = CommandType.StoredProcedure
.CommandText = "Add_User_Role"
End With
Dim paramReturnValue As New OracleParameter()
paramReturnValue.ParameterName = "@return_value"
paramReturnValue.OracleType = OracleType.Int32 ' here want to use boolean but doesnt have in enumeration.
paramReturnValue.Direction = ParameterDirection.Output
Dim paramUserId As New OracleParameter()
paramUserId.ParameterName = "@UserId"
paramUserId.OracleType = OracleType.Int32
paramUserId.Direction = ParameterDirection.Input
paramUserId.Value = UserId
Dim paramSftwrId As New OracleParameter()
paramSftwrId.ParameterName = "@SoftwareId"
paramSftwrId.OracleType = OracleType.Int32
paramSftwrId.Direction = ParameterDirection.Input
paramSftwrId.Value = 42
Dim paramRoleNo As New OracleParameter()
paramRoleNo.ParameterName = "@RoleNo"
paramRoleNo.OracleType = OracleType.Int32
paramRoleNo.Direction = ParameterDirection.Input
paramRoleNo.Value = RoleNo
'cmdUserRoleFunc.Parameters.Add(paramReturnValue)
cmdUserRoleFunc.Parameters.Add(paramUserId)
cmdUserRoleFunc.Parameters.Add(paramSftwrId)
cmdUserRoleFunc.Parameters.Add(paramRoleNo)
cmdUserRoleFunc.Parameters.Add(paramReturnValue)
cnContract.Open()
cmdUserRoleFunc.ExecuteScalar() 'Gives me error here..that illegal variable
Pls. Help me..i just wanted to get rid of this problem
Thanks anyways,
hemaxi
|
|
|
|
|
HEy
Thanks you all for helping me.
but now its working..i changed returnvalue boolean to integer.
so for sure function and stored proc both are not working when it return type is boolean in vvb.net
Thanks neways
hemaxi
|
|
|
|
|
I've got a web service running, and i'm trying to build tracing in it that gets outputted to a file. Unfortunately, i can't find a way of enabling TRACE token in a VB Website.
I don't want to use the ASP page trace dump, as it will break my SOAP interface.
This code is called on my application start event:
<br />
<br />
Dim lstrFileStream As System.IO.FileStream<br />
Dim objTraceListener As System.Diagnostics.TraceListener<br />
<br />
'Create Stream and Listener<br />
lstrFileStream = New System.IO.FileStream("C:\Temp\Tracer.Log", IO.FileMode.OpenOrCreate)<br />
objTraceListener = New System.Diagnostics.TextWriterTraceListener(lstrFileStream)<br />
objTraceListener.TraceOutputOptions = Diagnostics.TraceOptions.Timestamp<br />
<br />
'Trace Item<br />
System.Diagnostics.Trace.Listeners.Add(objTraceListener)<br />
<br />
This is called at the start of one of the SOAP requests:
<br />
System.Diagnostics.Trace.Write("Add Account Called.")<br />
System.Diagnostics.Trace.Flush()<br />
This generates an empty file, and never writes anything too it.
While i am aware that this style of trace listener may not be ideal, i'd be happy with it writing anything right now.
Any thoughts?
Cheers Chaps
Tris
|
|
|
|
|
I am trying to specify a company name in a var within the app.config file.
Problem: The company name is "Fetch & Co. LCC"
The program balks when it hits the "&" symbol in the string.
Remove the "&" ---- works fine.
This has got to be something simple...
Additional info:
If I try to put the string in the assembly info file (as ProgramTitle) The title will be blank.
Thanks for any help.
|
|
|
|
|
For those who may run into similar problem:
So I kept digging...er googling and finally came up with the correct search term... "illegal characters in app.config"
Solution: The replacement for the illegal character "&" is "& a m p ;" (remove the surrounding quotes and spaces! Ignore HTML and PRE did not work for display purposes).
This works fine.
Thanks to anyone who may have been trying to find an answer to my question.
-- modified at 11:46 Monday 21st August, 2006
|
|
|
|
|
Not come across that particular problem in a config file, but have had similar problem with inserting company names in an Excel worksheet header. Solution was to have two &'s e.g.
"Fetch && Co. LLC"
Steve
|
|
|
|