hi every body.. i want to know how to fetch a particular data from a text file.. not the entire file and place those datas into some control like datagrid or dataview using C#.Net... pls help me out how to do this..Pls help me out.. i have doubt in C#?
u fill use System.IO namespace for that
i know vb.net,in vb.net i can do it.but i can read the first line
fileiovar.readline()
but i dont know how its in c#
if u want a part in a text file u can look for searching-techniques.but im sure its all about System.IOPls help me out.. i have doubt in C#?
Read data connections using text drive r..this may help you out..
Have a nice day
StreamReader class can be used for retrieving data from the text file. The programming logic varies depended on the type of data file.
IF You have no idea the actual data, but the data type is xml or html. You need to know its open tag and close tag, and the data is being placed between them. Following is the example in C#.NET in handling xml file.
--------------------------------------鈥?br>
int iopentag;
' this is for recording the position of opening tag
int iclosetagpos;
' this is for recording the position of closing tag
string stropentag = ';%26lt;name%26gt;';;
string strclosetag = ';%26lt;/name%26gt;';;
string strxmlcontent; (the file is in binary format, you need to encode it to text, otherwise it will not work. I can't remember how to do it at moment.)
string stractualvalue;
int inumberofcharacterstostrip;
'This value is to determine how many characters to strip
iopentag = strxmlcontent.indexof(stropentag);
if iopentag %26gt; -1 {
if iclosetag %26gt; -1 {
inumberofcharacterstostrip = iclosetag - iopentag - stropentag.size;
stractualvalue = strxmlcontent.substring(iopentag + stropentag.length, inumberofcharacterstostrip);
}else{
Message.show(';This file is invalid!!!';);
}
}
///////
This is an example of retrieving one data from the text file. In the realworld situation, the pesuedo-code is as follow:
--------------------------------------鈥?br>
Get the current postion of opentag
Do while current position is greater than zero
If the end tag position is greater than zero then
get the actual number of characters to strip by opentagpos less closetagpos less length of starttagstring
get the start position to strip by start tag pos. plus length of start tag string (might be less 1, please try!)
Using substring property (start position to strip, actual number of characters to strip)
Change the open tag pos by (strxmlcontent.indexof(stropentag, iendtagpos))
Else
set opentag pos is -1
End if
End While
if closetag is -1 then
Prompt the message ';the file is invalid';.
end if
I have provided the logic tailerd to your case, hope my message will solve your programming problems. Are you uni student?
how to datagrid
Friday, August 20, 2010
How to avoid entering duplicate in Database? I have already put an Index to the field so that the data will?
not be duplicated..My only problem is that error. The error always appear when i put the same data in the databse, and after that those duplicates were deleted from the database...how can I trap the error? the error is like this:
Run-time error '-2147467259 (80004005)
i try to trap it but it doesn't work that error always appear...
is their any alternative way to avoid entering duplicates in the database? or What is the right way to trap the error? Please help me i really need this to my thesis...Im now online this is my I.d ericgri20002000.
By the way im using ADO control and Datagrid ...PLease help meHow to avoid entering duplicate in Database? I have already put an Index to the field so that the data will?
You use create a constraint and create a unique key across the fields you don't want duplication. Most DB Engines allow you to specify to ignore duplicate records in a unique key field range. An Identity field doesn't necessarily remove duplicate values in supplement fields- only the ID field.
runtime error 80004005 refers to unrecognized database format.. what is the version of your access database? use Jet Ver 4.0 for access 2000/2003.. Jet 3.5.1 for access 97.. take careHow to avoid entering duplicate in Database? I have already put an Index to the field so that the data will?
Create a method to verify that the data that you鈥檙e entering does not already exist prior to updating your table in the database. The method should execute a stored proc that will simply query the table for the specified value and then return the record ID if it exists. If it鈥檚 already there, then just don鈥檛 attempt to perform the insert.
If you wanted to get more complicated you could use Ajax to check the database for the value as the user is actually typing it on the page and instantly notify the user that the value already exists preventing them from inserting the duplicate value on the client side. You would need to develop a Web service for this and learn how to use Ajax.NET or write your own JavaScript SOAP call methods to interact with the Web service.
Run-time error '-2147467259 (80004005)
i try to trap it but it doesn't work that error always appear...
is their any alternative way to avoid entering duplicates in the database? or What is the right way to trap the error? Please help me i really need this to my thesis...Im now online this is my I.d ericgri20002000.
By the way im using ADO control and Datagrid ...PLease help meHow to avoid entering duplicate in Database? I have already put an Index to the field so that the data will?
You use create a constraint and create a unique key across the fields you don't want duplication. Most DB Engines allow you to specify to ignore duplicate records in a unique key field range. An Identity field doesn't necessarily remove duplicate values in supplement fields- only the ID field.
runtime error 80004005 refers to unrecognized database format.. what is the version of your access database? use Jet Ver 4.0 for access 2000/2003.. Jet 3.5.1 for access 97.. take careHow to avoid entering duplicate in Database? I have already put an Index to the field so that the data will?
Create a method to verify that the data that you鈥檙e entering does not already exist prior to updating your table in the database. The method should execute a stored proc that will simply query the table for the specified value and then return the record ID if it exists. If it鈥檚 already there, then just don鈥檛 attempt to perform the insert.
If you wanted to get more complicated you could use Ajax to check the database for the value as the user is actually typing it on the page and instantly notify the user that the value already exists preventing them from inserting the duplicate value on the client side. You would need to develop a Web service for this and learn how to use Ajax.NET or write your own JavaScript SOAP call methods to interact with the Web service.
My GUI problem?
hi,
I've a problem figuring out how to design my website's interface.
I have a menu control that's horizontal..it takes the whole width of the screen and right under it I have datagrid that also takes the whole width of the screen, so my problem is that new items are added in the menu regularly so that means the menu will be too wide for the screen..so I was thinking of converting it to a vertical menu but my problem is that the grid also takes the whole screen so I don't know where exactly to put it so this means it's gonna take part of the width that the grid takes?
So I can't imagine where to put it exactly...any suggestions..maybe some links to websites as examples..
thanksMy GUI problem?
First of all you should use css for the page layout. if you don't wana use them try specifying the width of each td tag in percentages in which you want to keep the display items of your webpage. once you have a stremlined table structure, adding or removing more items from page won't be any problem. using this approach you can have your extra item in either vertical or horizontal part. also you can restrict the datagrid to couple of TD/colums by specifying the the colspan attribute. or you can include the datagrid within the div tag and make the size of div tag smaller than the size of datagrid, so you can have scrollbars around the datagrid to view data and also increasing the space for you.love myspace myspace girl
I've a problem figuring out how to design my website's interface.
I have a menu control that's horizontal..it takes the whole width of the screen and right under it I have datagrid that also takes the whole width of the screen, so my problem is that new items are added in the menu regularly so that means the menu will be too wide for the screen..so I was thinking of converting it to a vertical menu but my problem is that the grid also takes the whole screen so I don't know where exactly to put it so this means it's gonna take part of the width that the grid takes?
So I can't imagine where to put it exactly...any suggestions..maybe some links to websites as examples..
thanksMy GUI problem?
First of all you should use css for the page layout. if you don't wana use them try specifying the width of each td tag in percentages in which you want to keep the display items of your webpage. once you have a stremlined table structure, adding or removing more items from page won't be any problem. using this approach you can have your extra item in either vertical or horizontal part. also you can restrict the datagrid to couple of TD/colums by specifying the the colspan attribute. or you can include the datagrid within the div tag and make the size of div tag smaller than the size of datagrid, so you can have scrollbars around the datagrid to view data and also increasing the space for you.
How to get value from datagrid to textbox outside grid in asp.net?
how to get value from datagrid to textbox outside grid in asp.netHow to get value from datagrid to textbox outside grid in asp.net?
in Asp Net data grid is associated with DataSet. Whenever there is change in data dispalyed in datagrid, dataset is updated accordingly. You need to read dataset for getting that value.
in Asp Net data grid is associated with DataSet. Whenever there is change in data dispalyed in datagrid, dataset is updated accordingly. You need to read dataset for getting that value.
I am a newbie in visual basic and i am having a hardtime controling my database using vb as my interface?
would you please help me on how i would code my vb program so that it would accept inputs via textboxes, confirm the inputs using a command button and save it in a database (access via adodc) that would then be displayed in a datagrid.
i already used adodc1.recordset.addnew and adodc1.recordset.update but what i need is a code because im going to use sql statements for queries with certain conditions.
one example is in my login form. I need to query my database using adodc to verify if the logging user is registered to the database. how could i solve this? please help me...I am a newbie in visual basic and i am having a hardtime controling my database using vb as my interface?
Been a while for VB and ADODC but as I recall, click on properties for the ADODC control and a wizard opens. You can select that you're using a SQL query, which kind of database you're connecting to (Access, SQLServer, etc) write the query in a box in the wizard and test the connection.
Hope that helps
i already used adodc1.recordset.addnew and adodc1.recordset.update but what i need is a code because im going to use sql statements for queries with certain conditions.
one example is in my login form. I need to query my database using adodc to verify if the logging user is registered to the database. how could i solve this? please help me...I am a newbie in visual basic and i am having a hardtime controling my database using vb as my interface?
Been a while for VB and ADODC but as I recall, click on properties for the ADODC control and a wizard opens. You can select that you're using a SQL query, which kind of database you're connecting to (Access, SQLServer, etc) write the query in a box in the wizard and test the connection.
Hope that helps
How can I use Function keys to display data in VB6.0?
Dear Friend
Can anybody answer about my below requirement?
I want to use function keys in my “Inventory Control System” software. I’m using VB6.0 and for database Access 2002.
For example, I want to see the availability of Computer based on ref_no (ref_no does exist in a TextBox which is placed on my MDI form). Then if I press F2 or F3 or F4 …., that particular item i.e. Computer related with ref_no will be displayed on a DataGrid.
Please help me about the use of function keys.
Appreciate, if you would come back at your earliest.
Regards
PervezHow can I use Function keys to display data in VB6.0?
You will need to place a keyup handler on your form and process the keys that come in
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyF1 Then myFunction()
End Sub
Can anybody answer about my below requirement?
I want to use function keys in my “Inventory Control System” software. I’m using VB6.0 and for database Access 2002.
For example, I want to see the availability of Computer based on ref_no (ref_no does exist in a TextBox which is placed on my MDI form). Then if I press F2 or F3 or F4 …., that particular item i.e. Computer related with ref_no will be displayed on a DataGrid.
Please help me about the use of function keys.
Appreciate, if you would come back at your earliest.
Regards
PervezHow can I use Function keys to display data in VB6.0?
You will need to place a keyup handler on your form and process the keys that come in
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyF1 Then myFunction()
End Sub
MS Access search form -> open report?
scenario:
FormName:frmSearch
objects: (all unbound)
txtBeginDate
txtEndDate
cboNameList (contains Names from tblNameList onLoad event)
cboCategoryList (contains Category from tblCategoryList onLoad event
() Show Detailed report (option bution to open dtlMonthlyReport)
() Show Summarized report (option bution to open smrMonthlyReport)
() Search Reciept (option button to open rcptReport)
() Search Voucher (option button to open vcrReport)
btnSearch
[ I want to display search result here within the form ... but dont konw how?]
================= end of frmSearch ==============
notes:
all the reports are link to its own form and the date field formated to accept input from within the form
the purpose of this form (frmSearch) is to show the search result based on user defined criteria and then from the search result user can double click to open the designated report with the parameters from the sellected search result.
question:
1) how do I display the search result(s) within the form itself (in VB its dataGrid) for the option 3 %26amp; 4 only.
2) I have tried using the ';SELECT '; method in sqlCriteria string using
doCmd.OpenReport .......,sqlCriteria
but an error msg appears saying ';....there are more than 1 record based on ..... consider using EXISTS reserved word ......';
So how do I open the designated report based on the search criteria?
I have heard of this PARAMETERS in querydef but not sure how to use it.
can you guys help me? Im stuck. whenever I want to display the reciept of a certain transaction I have to manually browse to the records (in frmTransaction) then click the button to generate the report. The same goes to the monthly detailed report, where I have to execute the form , enter the date range and click the button. For the summarized report its more troublesome for me to generate the report because it goes through many process. That is why i want to have this ';short cut';MS Access search form -%26gt; open report?
dont look for a shortcut please.
FormName:frmSearch
objects: (all unbound)
txtBeginDate
txtEndDate
cboNameList (contains Names from tblNameList onLoad event)
cboCategoryList (contains Category from tblCategoryList onLoad event
() Show Detailed report (option bution to open dtlMonthlyReport)
() Show Summarized report (option bution to open smrMonthlyReport)
() Search Reciept (option button to open rcptReport)
() Search Voucher (option button to open vcrReport)
btnSearch
[ I want to display search result here within the form ... but dont konw how?]
================= end of frmSearch ==============
notes:
all the reports are link to its own form and the date field formated to accept input from within the form
the purpose of this form (frmSearch) is to show the search result based on user defined criteria and then from the search result user can double click to open the designated report with the parameters from the sellected search result.
question:
1) how do I display the search result(s) within the form itself (in VB its dataGrid) for the option 3 %26amp; 4 only.
2) I have tried using the ';SELECT '; method in sqlCriteria string using
doCmd.OpenReport .......,sqlCriteria
but an error msg appears saying ';....there are more than 1 record based on ..... consider using EXISTS reserved word ......';
So how do I open the designated report based on the search criteria?
I have heard of this PARAMETERS in querydef but not sure how to use it.
can you guys help me? Im stuck. whenever I want to display the reciept of a certain transaction I have to manually browse to the records (in frmTransaction) then click the button to generate the report. The same goes to the monthly detailed report, where I have to execute the form , enter the date range and click the button. For the summarized report its more troublesome for me to generate the report because it goes through many process. That is why i want to have this ';short cut';MS Access search form -%26gt; open report?
dont look for a shortcut please.
Subscribe to:
Posts (Atom)