|
Hi i have a problem on how to create a .csv file using vb.net in windows appliaction. i am required to read information from a dataset and then retreive some certain information to create this .csv file. Problem is i do not know how to create the file and i need to save it to a location without prompting the user to select where to save. need help urgently and informations pls let mi knows thanks a millon.
KaKaShi HaTaKe
|
|
|
|
|
Hi There
Bascially a csv file is a plain text file holding records line by line, each field on the line seperated by a comma (,)
You need to open/create a file using the system.io objects
use a datareader of sorts to access your dataset tables row by row
create a string of each row like so:
field1,field2,field3,field4....etc
then write that line to the file, each line = 1 row
then capture the next row and recreate your string with fields seperated by , (commas) and so forth. I could easily write the code here but I think you would learn more if you attempt it. Its easier than it sounds
|
|
|
|
|
Dear All
i m new to vb.net .in my first application i move the datareader feild to one
text control but on screen it text box control display last 3 charecters and rest of value is there but cursor postion comes at the end of control,how to set this property.
Regards
Syed Nabeel Rashid
|
|
|
|
|
Check out this link
http://www.vbcity.com/forums/topic.asp?tid=20175
Navi
|
|
|
|
|
hi,
Is there a way to increase the number of the maxDropDownItems in the comboBox column of a DataGridView or a way to customize it , so it can allow more than 100 items, and how can I add vertical ScrollBar for the combobox , in Vb.Net
Regards,
MK
|
|
|
|
|
Hi All.
I am using ADO, Visual Basic 6.0 to connect to the dbf file to query corresponding table. After finish the query, I've closed the record set and the connection but I still could not rename that file (renaming is used for another purpose). Windows says that the file is in use by other person or application. I can only rename the file when the application using the connection above close (shutdown). Please tell me know to release completely to that file even though the application is still running.
Thanks so much.
Arien.
|
|
|
|
|
Make sure that every object that uses the connection is closed. You may have to set each db object to nothing also. Go through your code line by line and ensure every mention of the database connection has been closed properly. There must be an object still connected somewhere, especially if you close the app you are able to rename it. Also you may have to give the objects a little amount of time to complete its closing events before you can access the file to rename it. Hope this helps!
Highlander
|
|
|
|
|
Thanks so much Highlander.
Hieu Nguyen
|
|
|
|
|
Problem solve to delete multiple record at once:
Set rr = DB.OpenRecordset("SELECT * from DO where [NO] = " & dono.Text)
Do
rr.Delete
rr.MoveNext
Loop Until (rr.EOF)
rr.Close
Set rr = Nothing
-- modified at 22:56 Tuesday 29th August, 2006
|
|
|
|
|
Why not try writing a delete query?
|
|
|
|
|
Write an SQL query like this:
DELETE * FROM DO WHERE [NO]= [your_value_here]
...connect to your database and use the execute command to run this query.
|
|
|
|
|
Why are you settings a connection string for the connection, then using a different connection string?
Is the no field text or numeric? In the delete query you are using a string value, but in the select query you are using a numeric value.
After the delete query, don't delete anything from the recordset. As you are not opening the recordset in this code, it may contain anything from any previous code, and you may be deleting something completely different.
---
b { font-weight: normal; }
|
|
|
|
|
It's more a question about "wat" you should delete...
I've commented out the lines that you should remove:
Set cn = New adodb.Connection
' cn.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source= db1.mdb"
cn.Open constr ' constr is a connection string
sqlsql = "delete * from [DO] where no = " & "'" & dono.Text & "'"
cn.Execute sqlsql
' Do
' rr.Delete
' rr.MoveNext
'
' Loop Until (rs.EOF)
' rr.Close
' Set rr = Nothing
sql = "select * from DO where [NO]= " & dono.Text
doadodc.RecordSource = sql
doadodc.Refresh
MsgBox ("Record Deleted")
As you haven't answered the question about the data type of the "no" field, I don't know if you should keep the apostrophes in the query or not.
---
b { font-weight: normal; }
|
|
|
|
|
campbells wrote: is comment the this line it will have error so i remain put it in.
' cn.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source= db1.mdb"
Ok, so then the constr variable that is supposed to contain the connection string doesn't? Don't use it then.
campbells wrote: and i cant remove this because it will not delete anything from my program...but i think i found the error here... when i use this code it will totally delete my whole table record... i think because i set
rr = DB.OpenRecordset("DO"), but is it possible to set rr = DB.OpenRecordset("delete * from [DO] where NO = " & dono.Text)?? i mean put sql in it.. it not really working actually.
I think that you should read up a bit on what SQL queries do and how the Recordset object works. If you want to delete the records using SQL, you don't use a recordset at all. If you want to delete the records using a recordset, you only use a select query to specify what the recordset contains.
---
b { font-weight: normal; }
|
|
|
|
|
campbells wrote: how do i put the SQL in the recordest? cause when i put rr = DB.OpenRecordset("DO"), it mean the whole table in DO.
What you are using is the command type TableDirect, meaning that you open the entire table. If you use an SQL query instead, you will be using the command type Text, meaning that the query is used to select the records for the result.
campbells wrote: ACtually my SQL to select specific record only
delete * from [DO] where NO = " & dono.Text
No, that is not a query to select records, that is a query to delete records.
---
b { font-weight: normal; }
|
|
|
|
|
Please don't remove the original post and delete your postings. You have just made the entire thread totally incomprehensible.
---
b { font-weight: normal; }
|
|
|
|
|
i work with visual basic 6 and i use crystal report 10
but there are many problems:
1- the report view the data correctly only once, when i change the data of the table that is connected to the reprot the report doesn not view the
new data
EX. when i add new matrial to the matrials table and then show the report
the report does not show the new matrial
2- how can i pass value from the FORM contrlos (textbox) to the crystal report formula
Which easy crystal or data report
please help
thanx
BE OR NOT TO BE
|
|
|
|
|
Hello,
This sounds simple and yet I am lost as to how to get this to work.
I need to get a public class (CLASS 1) with no user interface to be able to write in another Form's textBox, however I am unable to do so. I can get text to show up on initialization based on my new() call, however any subsequent timer based updates to my textbox does not write anything; I do however see my debug message at the console.
How to I get 1 class to be able to write to a text box in another class ?
Here is sample code
<pre>
Public Class EXTERNAL
Private _Timer As Timer = Nothing
Private Const TIMER_INTERVAL As Long = 5000L
Public Sub StartTimer()
_Timer.Change(0, TIMER_INTERVAL)
End Sub
Public Sub New()
ReadSchedule()
_Timer = New Timer(New TimerCallback(AddressOf timertrigger), Nothing, Timeout.Infinite, Timeout.Infinite)
StartTimer()
End Sub
Public Sub ReadSchedule()
Dim qq As Info
For Each qq In Collection
Form2.TextBox1.AppendText(Date.Now & vbTab & qq.Name)
Next
End Sub
Public Sub timertrigger(ByVal state As Object)
Dim currentTime As DateTime = DateTime.Now
Console.WriteLine(Date.Now & " Debug message loop ")
Form2.TextBox1.appendText(Date.Now & " Debug message loop ")
End Sub
End Class
</pre>
Upon initialising my CLASS EXTERNAL with a new in my form2,
form2.textbox1 has the initial values from ReadSchedule() ... however when the timer hits (every 5 seconds), I see a console output for my debug message, but the form2.textbox1 does not change.
Any suggestion would be greatly appreciated.
Sincerely
|
|
|
|
|
IMO a better way would be to have the class fire an event and then in the event handler of the host object (the form that creates the instance of your class) handle the event and write the text to the text box. You can pass the text via an event argument from your class to the host object.
Keeping in mind with the important tenants of OOP, you should build your classes with the intent to keep them completely isolated components and fully encapsulate them and what they do from anything else. Building a class that makes a direct connect (as your code does) to something else (the text box) tightly couples that class to that implementation is therefore violates good OOP principals. It makes it hard to reuse, it makes it hard to unit test and it makes it hard to maintain.
BTW, the reason you are not seeing anything happen on the host form is because you are referencing the text box NOT an instance of that text box. You could TRY passing an instance of the form into your class contrsuctor and referencing that in your timer function but then you would be violating more than good OOP because you would be acting on a GUI component outside the thread that created it.
|
|
|
|
|
hi my friend
i have this problem ??
I get this error :
==================
(Operation not yet implemented) When I use Crystal Reports 10 to Print Or Export
I am using vb.net asp.net and windows 2003 server .
thank you all
Nsr
|
|
|
|
|
I am trying to get used to with automated data ui generation tools in vs2005. I generated an input ui just by dragging detailed view of an table from data sources pane. It created binded sources and even a navigator for data source. everything is fine up to here but i just dont like the names of controls generated. is it possible to change naming style of these auto generated controls automatically?
for example: FirstNameTextBox -> txtFirstName
|
|
|
|
|
Nope, not as far as I know.
Some third party add on tools DO allow you some level of customization to the emitted code they create though, that's what makes them more attractive than using the 'free' stuff included in the IDE.
|
|
|
|
|
Hi i have a requirement in one project in vb.net 2005
There is employee master with reports to field and from this table i need to create a organization chart in VB.net
Is there any sort of example available or anyone can give me some guidance regarding the same.
Regards
Riyaz Zujer Patanwala
I.T.Programmer
Al Jaber Energy Services
P.O.Box 47467
Abu Dhabi
U.A.E.
|
|
|
|
|
Dundas has a charting library that would probably be the easiest way for you to achieve this task.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi everyone
Im using VB.Net 2003. I have a field in a datagrid "Total", how do i calculate the total and Display it in a label
|
|
|
|