|
thanks, I never thought it would be done like that. I will see what I can do.
|
|
|
|
|
Is there a simple function similar to FileCopy that allows wildcards. I want to copy multiple files rather than one file at a time.
I am using VB 6
Any assistance appreciated.
Mike
New to IT
|
|
|
|
|
Use System.IO.Directory and its "Move" method to move the entire contents.
If you are specific about the file types use "Getfiles" method and get them into a string array and copy them.
Cheers
|
|
|
|
|
Murugavel S wrote:
Use System.IO.Directory
He's using VB6.
"if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler.
|
|
|
|
|
I am a little confused with all of these. Right now to pull data from the db ans display it I use a dataAdaptor, dataSet, dataGris, and a dataView. Now this all works for me, but I am sure that I am only skimmig the surface. Seeing as everything works with what I use, what are dataRows, and DataCols for? Are they for creating your own columns within a pre-defined or manually created dataSet.
I am presently trying to replace a class structure simular to a Book->page->word like structue with a dataset, and use dataviews to view all the data the corresponds to the page being viewed, and I think that this might be a much better way than what I have now.
Thanks for any input.
|
|
|
|
|
DataRow represents a single row of a datatable. i.e to display / insert a single row of a datatable.
DataColumn represents a single column of a datatable. A new column can be created in the datatable in otherwords to create the schema of Datatable.
You can set Constraints, Identity, Null/Not Null.
Now, datarow can be used to create a new row in a datacolumn.
Basically, think the above two as equivalent to the action that you carry out in your database server.
Cheers
|
|
|
|
|
I am not sure if this way of thinking is right, but...
Are creating data columns and dataRows, used more for allowing for control of what is going into the dataTable? I was thinking that maybe when using the dataAdaptor that the dataCols, etc is all down behind the scene.
Another question though.
I can't seem to figure out how to set up a data view to only show certain columns. There is a rowFilter, which is obviously like the where clause in an sql string, but right now I need to be able to only show the cols that I want. Does anyone know how to do this. The book that I found only has a half a page on the dataView so there is not much detail on this subject.
Thanks for the help
|
|
|
|
|
datacolumns are used for defining the structure or schema of the data table. so, in a sense, yes your thinking is correct.
when using dataadapter.fill, the datatable you point to assumes the structure of the resulting data.
for data views, i don't believe you can filter columns out of a view. to do this, you would use whatever tool you're using to display the data table to the user. i.e. a datagrid or combobox etc.
if using a datagrid, define a tablestyle for your datagrid and then define a gridcolumnstyle for each column you wish to actually display. don't define one for the columns you wish to hide, or you could define the grid columnstyle for the ones you wish to hide and just set their width property to 0.
hope this helps.
- jim
|
|
|
|
|
that makes sense. I made things work by creating a custom table inserting only the cols that I want then the corresponding data for those columns, BUT if I make changes to that data, is it going to affect the data in the dataSet and therefore be able to be submitted, since the custom dataTable that is created is not part of the dataSet?
Thanks again
|
|
|
|
|
no problem.
i would advise against doing it the way you said you were able to get around your problem for two main reasons.
1. you are going to have problems updating back to the datasource. this is because you've changed the structure of the table. when you use fill from the dataadapter to populate a table the dataadapter itself holds information regarding the information that was pulled and automatically creates insert, update and delete statements based on the structure of what was initially pulled. you could certainly call myAdapter.Update(myNewTable) but it will no doubt cause problems because the structure has changed. This is of course unless you manually update the commandtext property of the corresponding commands to reflect the structure of the new table.
2. you are incurring an unnecessary performance hit by copying the data from the table that is returned by the adapter into a new table. this will be more of an issue as the amount of data returned increases.
so basically, you can do it this way, but i don't really think it's necessary in your situation. my recommendation would be to just pull the data out using the dataadapter, let the user update the data, and use the same dataadapter to update, if possible.
If using the same dataadapter isn't possible, then you have to look into how to set the properties of the dataadatper and it's underlying Insert, Update, and Delete Commands and their corresponding CommandText properties to get the data back into the database correctly.
- jim
|
|
|
|
|
I kinda thought that it might be a problem. I am trying to get a dataGrid style to work, but I can't find a lot on it. This is what I have so far on the methods that links the dataSet and the dataGrid
I have created the style through the menus, creating the grid style and all column styles to hide certain columns, but I am having a hard time makig the datagrid use the style. There does not seem to be a lot written on this subject.
|
|
|
|
|
i had a hard time when first using these as well. the more you use them the easier it gets.
i would say first, make sure that all of the mappingname properties for the tablestyle and columnstyles are spelled correctly.
tablestyle.mappingname should = datatable.tablename
columnstyle.mappingname should = datatable.cols(x).columnname (i.e. the column it should map to)
if the grid isn't using the tablestyle at all the most likely culprit would be the tablestyle mappingname property.
-jim
|
|
|
|
|
ya it was the tableStyle mapping property, but I was leaving that out because I was trying to set that within the code to allow different functions to display different columns.
Is the mapping name mor for assigning different styles to different tables within the datagrid? Because I can't figure out how to do it via code.
|
|
|
|
|
ok, I think I am just too tired to think, but I see how to do it now. Disregard that last post.
|
|
|
|
|
well I got everything working the way that I want to. Thanks again for the help
|
|
|
|
|
no problem, glad it worked out for ya. sorry for the lack of responsiveness, i had left work and have spent the last few hours playing in the backyard with my daughter... some things are more important you know.
just in case though, as for the last post, if you just create multiple tablestyles and give them the appropriate mapping name based on the table you want them to display, the grid will take care of handling everything for you. then you can have the parent table display one way (for example: light blue background) a first child table another (light green background) and a second child table a third (orange background) it's pretty flexible. the ony real downside is the maintenance if columnnames change etc.
take it easy.
-jim
|
|
|
|
|
what if you want different table styles pointing to the same table. The app that I am working on is one that is used to correct tests. There is more than one type of error. Right now I have all the data being retrieved and thrown into the same table. I may have to change this is base the query on the correction mode and insert the data into different datatables, I really should do this, but I am still curious of the present problem.
I would like to create tablestyles, which I though that I did, so that in the different correction modes different columns are displayed, but I get an error when I try to do this:
<br />
An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll<br />
<br />
Additional information: The data grid table styles collection already contains a table style with the same mapping name.<br />
Now they are the same mapping name, because the mapping name is the name of the table right?
Thanks for the help
|
|
|
|
|
I know that in listview or other control, we can do right click event using MouseUp. However, menuItem of Mainmenu doesn't have that. Could somebody please show me how to implement right click event on MenuItem of Mainmenu in vb.net?
Thanks a bunch for helping.
|
|
|
|
|
In theory, you would have to derive a new class from the MainMenu class and override its WndProc to handle the WM_RBUTTONDOWN message with you own custom right-click code.
But, Right-clicking on menu items is not part of the Windows user interface standards, so users don't normally right click on menu items. For instance, Menu Tear-offs are normally accomplished using a Left click and hold, then drag.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I am using MMControl for playing a midi file on my software. I have never had it work on my computer, but the computer that I originally programmed on never had a problem. I am getting the error
"Run-time error '424':
Object required"
and the Debug option takes me to the first line where I use MMControl. I have also tried it on someone elses computer and it works fine. I attempted to take the code from their computer back to mine and I get
"Errors during load. Refer to <some path="">.log' for details"
I visited the log file and find
Line 13: Cannot load control MMControl; license not found.
Which to me is an odd error. What does this mean I need to do?
Thanks in advance,
Red Sunday
-----------------
http://www.zachcalvert.com
|
|
|
|
|
You must copy over and register the MMCONTROL.OCX and, if you have it, the MCI32.OCX file on the target machine. You can't just copy it over and expect it to work. If it is already in the System32 directory on the target machine, unregister and register the control.
C:\WINDOWS\SYSTEM32>regsvr32 /u mmcontrol.ocx
C:\WINDOWS\SYSTEM32>regsvr32 mmcontrol.ocx
Do the same for MCI32.OCX.
If it still does not work, you'll need a fix the license information in the registry.
See this[^] article on MSDN for more information.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I tried the regsvr32 bit and it didn't work.
First off, the working computer does not have mmcontrol.ocx it only has the MCI32.ocx. We un-registered and re-registered this file and get the same error.
Next, we are using VB 6.0 on BOTH systems. Neither one are using the .NET structures. I appreciate your help...we are soooo stuck.
Red Sunday
-----------------
http://www.zachcalvert.com
|
|
|
|
|
In that case, the licesing is screwed up and you have to refere to the Microsoft page I put in my first post. What you need to do is get ahold of MS Support as directed in that page and they'll send you a reg file that will correct the problem.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I found some vb script code on the internet that can convert a comma delimited text file into an mdb file. Here is the code.
--------------------------------------------------------------------------
'NBM 04/10/2001
'Declare constants
Const Jet10 = 1
Const Jet11 = 2
Const Jet20 = 3
Const Jet3x = 4
Const Jet4x = 5
'Routine to create MDB file.
Sub createNewMDB(FileName, Format)
Const adInteger = 3
Const adVarWChar = 202
Const adVarChar = 200
Const adCollNullable = 2
Dim Catalog
Set Catalog = CreateObject("ADOX.Catalog")
Catalog.Create "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Jet OLEDB:Engine Type=" & Format & _
";Data Source=" & FileName
Dim objListTable, objColumn
Set objListTable = CreateObject("ADOX.Table")
objListTable.Name = "List"
objListTable.Columns.Append "TestCount", adVarWChar, 40
objListTable.Columns.Append "TestTime", adVarWChar, 50
objListTable.Columns.Append "TestDate", adVarWChar, 50
objListTable.Columns.Append "SerialNumber", adVarWChar, 50
objListTable.Columns.Append "CylinderSize", adVarWChar, 40
objListTable.Columns.Append "CylinderService", adVarWChar, 30
objListTable.Columns.Append "CylinderManufacturer", adVarWChar, 10
objListTable.Columns.Append "DOTRating", adVarWChar, 35
objListTable.Columns.Append "TestPressure", adVarWChar, 30
objListTable.Columns.Append "ActualPressure", adVarWChar, 20
objListTable.Columns.Append "TestDuration", adVarWChar, 20
objListTable.Columns.Append "TotalExpansion", adVarWChar, 45
objListTable.Columns.Append "PermExpansion", adVarWChar, 45
objListTable.Columns.Append "PercentPermanentExpansion", adVarWChar, 45
objListTable.Columns.Append "ElasticExpansion", adVarWChar, 45
objListTable.Columns.Append "REE", adVarWChar, 45
objListTable.Columns.Append "Disposition", adVarWChar, 45
objListTable.Columns.Append "PlusStar", adVarWChar, 45
objListTable.Columns.Append "Remarks", adVarWChar, 45
objListTable.Columns.Append "CylinderOwner", adVarWChar, 45
objListTable.Columns.Append "NotKnown", adVarWChar, 45
objListTable.Columns.Append "Source", adVarWChar, 45
objListTable.Columns.Append "ManufactureDate", adVarWChar, 45
objListTable.Columns.Append "Unit", adVarWChar, 45
For Each objColumn in objListTable.Columns
objColumn.Attributes = adCollNullable
Next
Catalog.Tables.Append objListTable
End Sub
Sub convertCSVtoMDB(AccessFile, CSVFile)
Const adOpenStatic = 3
Const adLockReadOnly = 1
Const adCmdText = &H0001
Const adOpenDynamic = 2
Const adLockOptimistic = 3
Dim fso, FileCSV
Set fso = CreateObject("Scripting.FileSystemObject")
Set FileCSV = fso.GetFile(CSVFile)
Dim objConn, objRs
Set objConn = CreateObject("ADODB.Connection")
objConn.Open "Driver={Microsoft Text Driver (*.txt; *.csv)};" & _
"Dbq=" & FileCSV.ParentFolder & ";" & _
"Extensions=asc,csv,tab,txt;" & _
"Persist Security Info=False"
Set objRs = CreateObject("ADODB.Recordset")
objRs.Open "Select * From " & FileCSV.Name, objConn, adOpenStatic, adCmdText
Dim objAccessConn, objAccessRs
Set objAccessConn = CreateObject("ADODB.Connection")
objAccessConn.Open "Driver={Microsoft Access Driver (*.mdb)};" &_
"Dbq=" & AccessFile & ";" & _
"Uid=Admin;" &_
"Pwd=;"
Set objAccessRs = CreateObject("ADODB.Recordset")
objAccessRs.Open "List",objAccessConn,adOpenDynamic,adLockOptimistic
Do While Not objRS.EOF
objAccessRs.AddNew
objAccessRs("TestCount") = objRs("TestCount")
objAccessRs("TestTime") = objRs("TestTime")
objAccessRs("TestDate") = objRs("TestDate")
objAccessRs("SerialNumber") = objRs("SerialNumber")
objAccessRs("CylinderSize") = objRs("CylinderSize")
objAccessRs("CylinderService") = objRs("CylinderService")
objAccessRs("CylinderManufacturer") = objRs("CylinderManufacturer")
objAccessRs("DOTRating") = objRs("DOTRating")
objAccessRs("TestPressure") = objRs("TestPressure")
objAccessRs("ActualPressure") = objRs("ActualPressure")
objAccessRs("TestDuration") = objRs("TestDuration")
objAccessRs("TotalExpansion") = objRs("TotalExpansion")
objAccessRs("PermExpansion") = objRs("PermExpansion")
objAccessRs("PercentPermanentExpansion") = objRs("PercentPermanentExpansion")
objAccessRs("ElasticExpansion") = objRs("ElasticExpansion")
objAccessRs("REE") = objRs("REE")
objAccessRs("Disposition") = objRs("Disposition")
objAccessRs("PlusStar") = objRs("PlusStar")
objAccessRs("Remarks") = objRs("Remarks")
objAccessRs("CylinderOwner") = objRs("CylinderOwner")
objAccessRs("NotKnown") = objRs("NotKnown")
objAccessRs("Source") = objRs("Source")
objAccessRs("ManufactureDate") = objRs("ManufactureDate")
objAccessRs("Unit") = objRs("TotalExpansion")
objAccessRs.Update
objRS.MoveNext
Loop
objAccessRs.Close
objAccessConn.Close
objRs.Close
objConn.Close
Set objAccessRs = Nothing
Set objAccessConn = Nothing
Set objConn = Nothing
Set objRs = Nothing
End sub
'Create Access2000 database
createNewMDB "c:\Program Files\csvdata\template.mdb", Jet4x
'Convert the CSV into the newly created MDB file.
convertCSVtoMDB "c:\Program Files\csvdata\template.mdb", "c:\Program Files\csvdata\export.csv"
--------------------------------------------------------------------------
When I run the code the export.csv file is converted into the template.mdb file. If the template.mdb file from the previous time that the code was run has not been deleted an error message "The database already exists". So I have to delete the mdb file everytime that I run the code.
I was wondering if there was a way that someone could explain to me, so that I would not have to delete the mdb file everytime? In other words the code would simply overwrite the mdb file. Is this possible? Could someone help me?
Thanks.
|
|
|
|
|
Do you want to delete the database file automatically so you don't have to do it by hand?
Or do you want to add the new data to the existing database?
The code you posted creates the database .MDB), then creates the table the data does into, the creates all the columns in the table. Do you want this database recreated every time you want the data imported from .CSV or do you want to append the new data to the existing database?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|