.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Equivalent C# function for this random access read for this VB6 function?

Posted By:      Posted Date: September 16, 2010    Points: 0   Category :ASP.Net
I'm having a problem reading a block of bytes into an array from a file read (random access).  Instead, in C#, it seems I can only read byte by byte and not a block of byte.  I want to create a string array that is 500 cells in capacity but each cell is 10 bytes wide.  how do i do this?I have  written the function in Vb6 and maybe someone can tell me the fs.Read (code) for the C# equivalent.In Vb6, I declaredPrvate Type WFM  points(500) as String * 10   // This will create an string array of 500 cells but the KEY here is each cell is 10 bytes wide fixed!End type

View Complete Post

More Related Resource Links

SQL Equivalent to the First Function in MS Access

Is there a sol'n?  I have looked all over the net and have not been able to find a thing.Here is copy Access code..SELECT ID, [Academic Year], Term, Location, [Student Section], [Creation Date], First(Date) AS FirstOfDate, First(Status) AS FirstOfStatus, First([Reg Status]) AS [FirstOfReg Status], First([Status Date]) AS [FirstOfStatus date] INTO [TEMPDB]FROM [StudentRecord]GROUP BY ID, [Academic Year], Term, Location, [Student Section], [Creation Date]ORDER BY ID, [Academic Year], Term, Location, [Student Section], [Creation Date], First(Date) DESC , First(Status) DESC;I hope this helps.

Error "The process cannot access the file ....." occurs while using function "ExportToStream"


Dear all,

   I sometimes get the following error while printing crystal report to pdf:

   System.Runtime.InteropServices.COMException (0x80004005): The process cannot access the file because
it is being used by another process. at CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.Export
(ExportOptions pExportOptions, RequestContext pRequestContext) at CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream
(ExportRequestContext reqContext) at CrystalDecisions.CrystalReports.Engine.FormatEngine.ExportToStream(ExportRequestContext reqContext)
 at CrystalDecisions.CrystalReports.Engine.ReportDocument.ExportToStream(ExportOptions options) at
 CrystalDecisions.CrystalReports.Engine.ReportDocument.ExportToStream(ExportFormatType formatType) at
 CommonWA.CommonFunc.GetPDFMemoryStream(DCMSReportDoc _dcmsreportdoc, Boolean& _DataExist) in E:\wwwroot\ASPWA\CommonWA\CommonCom.vb:line 382

  The error not occurs frequently but sometimes it will happen, can someone tell me why the error occurs and how can I solve the problem?

Thank you very much.


Access Public Function in MasterPage

Hi,I need help in accessing the function in my masterpage.I have a.master and b.aspx with the content page.Now in the page load of my content page, I want to execute the an sql query which is in a function in my master page.How can I access the function in my master page??code in my master page:public function info () as string'SQL Queryend function

Access UserControl Control from a JavaScript Function

I have a requirement to launch a Modal Javascript dialog box from within my usercontrol,I have done this by <code> function browseControlAction(ProjID,ControlID) { strPrompt = 'Select a Previous control action..'; strOptions = 'dialogWidth:25;dialogHeight:30;status:no;resizable:yes'; selectedAction = window.showModalDialog('browseControlActions.aspx?ProjID=' + ProjID + '&Control=' + ControlID, strPrompt, strOptions); var sControl = ' + ControlID + '; if (selectedAction != null) { alert(ControlID.toString()); alert(selectedAction); var sTest = ControlID + '_txtControlAction'; alert(sTest); var sTest2 = 'txtSummary'; alert(sTest2); document.getElementById('txtCurrentControls').innerText=selectedAction;   //this works as this a control on the page itself document.getElementById(sTest2).innerText=selectedAction;      //Ditto document.getElementById(sTest).innerText=selectedAction;    //This Fails as this is the control in the USercontrol I am trying to Access //__doPostBack('',''); }</code>can anybody tell me why I can't access the Textbox control on the USercontrol?

T-SQL Equivalent For Group_Concat() Function

Hello, I am looking for a way to do the MSSQL T-SQL equivalent of the MySQL aggregate function: group_concat(). We are running SQL 2005 Express. Is there a pure T-SQL way to do this, or if not, a way to create a new custom aggregate function? EX: SELECT GROUP_CONCAT(FIRST_NAME) AS STUDENT_LIST FROM STUDENTS GROUP BY TEACHER OUTPUT: JOSH,JOEY,MARK,LINDA,PAM,BILL,MIKE,JUSTIN

64 bit Strong Random function

i want to generate 64 Bit random number (Range between 2^50 and 2^64) in C#

How to read all function/method names from .cs file


 Hi everyone,

Normally i answer to the peoples questions here but today i am posting a question for a answer :)

I have a .cs file and i want to read all function/method names from it.

This .cs file is not part of my project or solution other wise i would have used reflection or codedom to do so.

The .cs file is a file on a disk to which i can accessing by giving its physical path say "C:\Sample.cs"

Is there any possibility that i can fetch all the function names declared in Sample.cs

Note: I am doing this for one of my requirement to find out dependencies in code

For example If class A is using some function from class B then class A is dependent on class B. this i need to find out and both this class files are simply a files residing on disk not even part of my project. 

User will select a directory first then any one of the .cs file in that directory and will click on button to find dependencies of that .cs file.

The application should traverse all other .cs files in that directory and find out on how many other .cs files the selected file is dependent.

FAQ: What is the equivalent function in C# for the function IsDate in VB?


What is the equivalent function in C# for the function IsDate in VB?

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.

Passing variable into function in SQL Server from Access



I am trying to call a function in SQL Server 2005 from Access 2003.  It works fine with the constant value, but fails with a variable of the same value.  This works:

strSQL = "SELECT * FROM functionName (constantValue)"
rs.Open strSQL, cn 

But when I use variable in the parameter, I get error.  I have tried creating parameter objects in Access, but couldn't execute it and don't know if this is a way to go anyway.

Would appreciate for any help or suggestion.


Thank you

StreamReader.BaseStream.Read() problem in Random access reading of file


I am trying to randomly access a file but not fully understanding this class.

I have

 // Seek to the beginning of the field

System.IO.StreamReader srFile = new System.IO.StreamReader(_FileName.PathAndFileName);

srFile.BaseStream.Seek(FieldOffset, SeekOrigin.Begin);

// Read the field

int FieldLength = Field.FieldLength;  

int BUFFER_SIZE = (int)RecordLength;

byte[] bBuffer = new Byte[BUFFER_SIZE];

srFile.BaseStream.Read(bBuffer, 0, (int)FieldLength);

string FieldValue;
FieldValue = bBuffer.ToString();

but bBuffer is numbers like:

[0] 32

and the value of FieldValue is "System.Byte[]"

I'm trying to get text as this is a text file.


How to use sql insert and left function is ms Access VBA module


I have table called main table and there is 2 columns in it "Department name" and "DeptID" Dept name column has values such as

DP302-Finance and DeptID column is empty. i want to write sql insert statement that will just select first 5 characters from Department name and insert into DeptID. for e.g DP302-Finance in Deptarment name should be copied into DeptID columns as DP302. I am using following sql in access module but i am getting synatx error in insert into statement.

Sub che()
Dim objDB As DAO.Database
Dim strsql As String
strsql = "insert into main .(DeptID) (select left [Department name, 5]as DeptId from main)"
Set objDB = CurrentDb()
  objDB.Execute strsql, dbFailOnError
  Set objDB = Nothing
End Sub

How do I access a network share from a CLR function




I wrote a CLR TVF for SQL Sever to retrieve the filenames in a directory. It contains the following code to retrieve the filenames:


Sub New(ByVal PathName As

Content page control passes as argument to javascript function


Here is the content page:


<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="JavaDynamicCopyValue.aspx.cs" Inherits="JavaDynamicCopyValue" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
 <script type="text/javascript" >
 function copyValue(input, output )
   ouput.value = input.value;
   return true;
 <asp:TextBox ID="txt1" runat="server" onchange="copyValue(this,document.getElementById('<%=txt2.ClientID%>'))"></asp:TextBox>
    <br />
    <br />
    <asp:TextBox ID="txt2" runat="server"></asp:TextBox>


I got a javascript run time error says output is undefined. if I view source of the page, the txt1 markup became:

<input name="ctl00$ContentPlaceHol

connection to SQL Server files (*.mdf) require SQL server express 2005 to function properly.


I dont have the SQL EXPRESS installed instead I have SQL Standard Edition.

 I have two SQL Server instances installed.

 1- UserLT (this is sql 2000)
2- UserLT\SQL2005 (this is SQL 2005 named instance)

But when i try to add a database to my VS website project I get the following error:

Connection to SQL Server files (*.mdf) require SQL server express 2005 to function properly. please verify the installation of the component or download from the URL: go.microsoft.com/fwlink/?linkId=4925

I went in Tools>Opetions>DataBase tools>Data Connection>Sql Server Instance Name (blank for default)

and changed the "SQLEXPRESS" to "USERLT\SQL2005".

But I still get the same error message. Any ideas how i can resolve this issue?

Public Shared function doubt????

I am using VB.net/ASP.NET and SQL Server 2000 for a web application.

For populating the dropdowns, I wrote a Public Shared function LoadDDL(), in which I pass the dataset and dropdown name to set.

I have my doubts that this function will produce unexpected results for concurrent users. And will mix the results among sessions because it is a Shared function.

I am confused here. Is it the right way to go?

Please advice. Thanks in advance.


Trim function in C Sharp

How do i use "trim" function in C Sharp? I have a string and i want to strip off spaces from the end of the string. Any idea how do i do it??


Pure C++: Invoking Generic or Function Templates


As I promised last time, in this month's column I'll walk through the process of defining and invoking a generic or template function under C++\CLI. A function template or a generic function begins with the template or generic keyword followed by its parameter list.

Stanley B. Lippman

MSDN Magazine October 2005

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend