|
Try this
byte[] buffer = new byte[streamObj.Length + 1];
And don't forget to vote the message
|
|
|
|
|
sumit7034 wrote: streamObj.Length + 1
WHY?
|
|
|
|
|
Because VB uses the highest index when declaring array, while C# uses the size.
The code is an exact translation of the VB code, but the VB code is probably not correct in the first place. It should most likely use streamObj.Length - 1 to create a buffer the same size as the stream, and the translation of that to C# would use streamObj.Length .
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Guffa wrote: Because VB uses the highest index
Great. It is new to me and thanks for correcting me. So it is not a zero based index?
|
|
|
|
|
Yes, it's zero based, but the upper limit in the Dim statement is the highest index in the array, not the size of the array.
Dim buffer(3) As Byte 'declares an array with four bytes
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Great Guffa... nicely explained.
Jey
|
|
|
|
|
|
Blue_Boy wrote: Bookmark this converter from VB.NET to C#[^]
It works for simple statements not for all.
|
|
|
|
|
Try this
byte[] buffer= null;
buffer=new byte[streamObj.length];
|
|
|
|
|
byte[] buffer = new byte[streamObj.Length + 1];
|
|
|
|
|
Use Always for convertion.........
http://labs.developerfusion.co.uk/convert/vb-to-csharp.aspx
|
|
|
|
|
Hi All
I'm trying to create a simple aspx page by pulling info from an existing excel sheet into a data grid.
What I need to do is apply some conditions to this so that certain info is displayed depending on certain conditions.
eg datagrid:
name nickname URL link
gerry http://gerry.com gerry
william bill http://william.com bill
What I need is if there's a value in nickname then the Text for the link will be that value, if not then it will be the name value.
I've tried creating a template column but can see anywhere to put an if statement in there either.
I'm new to all this and am not looking for someone to do this for me, just point me in the right direction as I want to understand why I'm doing what I'm doing.
I appreciate any pointers anyone can give me.
Rgds
gerryR
|
|
|
|
|
There are two ways you can do this:
Either in the ItemDataBound[^] event, or call a function[^] directly from your template column, passing the two values (name and nickname)
|
|
|
|
|
Thanks for that,
Couldn't get my head around the databound method, I'll save that for another day. Got the function method working although I ran into another problem with that (null values), I'll post a seperate message about that.
Thanks again
gerryR
|
|
|
|
|
hi all,
I got an error when i am trying to connect a web application on my local system with a remote DB.The error is
"An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
the web.config file contains the connection string
<add name="ConnectionString" connectionString="Data Source=Servername;Initial Catalog=GospelNews;User ID=userID;Pwd=passwordd;Connect Timeout=30;Trusted_Connection=Yes" providerName="System.Data.SqlClient"/>
Can anybody help me to come out of this problem.
Thanks in Advance
|
|
|
|
|
Check to make sure the connection works on a local machine, if it does then probably you're blocked by their firewall.
For security reasons many servers prohibit connection from a remote computer. I believe you need to contact web server support, they may let you give them an ip and they let it pass the firewall.
"In the end it's a little boy expressing himself." Yanni
|
|
|
|
|
There are several reasons for this, but first thing I noticed is that you use Named Pipes. Is this the protocol you want? Typically it's not on and it won't go through firewalls
Mika
|
|
|
|
|
How can i change it to tcp/ip?
|
|
|
|
|
|
Hi all,
i run my web application correctly on my local server and works well.After i hosted the same (only remote DB connection string changed) it shows the error
"Server Error in '/' Application.
Login failed for user 'vbb/bnm'"
Can anybody help me in finding what is wrong with the application.
Thanks.
|
|
|
|
|
reogeo2008 wrote: Login failed for user 'vbb/bnm'"
Does't this line explain itself...
Seems like its you do not have access to Database.
Hope this helps...
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Hey guys, i was wondering how do they create the seat selection and saving it them. [from www.gv.com.sg , buy tickets]
i find it very cool, but the selection and saving them i am not sure. Are there examples available ?
|
|
|
|
|
|
If that's really your username and password I suggest you edit your post to remove them
|
|
|
|
|
I have a gridview that in every row of it is a textbox.and i have a generic list.I want to show item of list in textboxes of gidview.for example ,if in list has 4 item like 1,2,3,4 ,and gridview has 7 rows,only 4 row of gridview must be complete.4 textbox in full and 3 textbox are empty.what should i do?
|
|
|
|