|
i use VB 6.0 with MS Access as a database. With the insertion in table1 i use to update a counter (N+1, ....) in table2. but some time table2 does not update its value and repeat the previous value. e.g if previous value is 2854 then it should be updated to 2855
Help please
|
|
|
|
|
It would be difficult to answer your question without looking into your code.
|
|
|
|
|
Code is very simple and i know how to code for insertion into database.
str="Update table2 set field1=val1, field2=val2 Where condition"
set rs=cn.execute(str)
but some time it misses to update a record.
|
|
|
|
|
Change your number-field to an auto-numbering field[^].
That way the number will increase itself, every time that you insert a table - without the need to track the highest number in a separate table.
I are Troll
|
|
|
|
|
You should be using autonumbering fields for your primary keys. Also, when you insert a record into Table1, you need to retrieve the ID that record got in the table, then use that ID in your query to update Table2.
|
|
|
|
|
Tufail Ahmad wrote: Update table2 set field1=val1, field2=val2 Where condition
This code will NOT insert anything into table2, ever wondered why ?
|
|
|
|
|
I will be the first to admit that I don't know what I'm doing. But I have dabbled a little here and there so I'm willing to give this a try...maybe you will too?
I work at a company with some very antiquated software. We have a program that was built using no less that 8 different DOS-based applications strung together. We've managed to keep this thing working for quit a while now and still add new data to the source files and recompile them regularly. But, we're getting pretty nervous about the age and complexity of this application and want to replace it with a database-driven application. The input to the application is a text file that contains a bunch of 5-digit alpha-numeric codes like "E5101" or "E5101QTY=2". Each code represents either some very specific instructions to our manufacturing shop or some Bill of Material data (BOM). For example the "E5101" code means to take the part we're building, put some glue into the hole, and then insert a bushing into that hole and let the glue dry. The example of the "E5101QTY=2" is a BOM code and it basically means that we will need two of the bushings that are used for the assembly. I hope this is clear as it is a simple but powerful concept.
Now, the output of the application is another text file which contains these same codes but in a logical order. For example the code to issue some raw material needs to come before the code to cut that material and that needs to come before a code to paint that material. And BOM codes need to be separated from codes that are work instructions. So the order of the codes has been revised based on some rules/tags/parameters that we have been assigning.
Finally, my question is how should I approach replacing this application with a database?
It is really pretty simple in some ways but is as complex as a geneology tree, which is one of the main software components that comprise this application. It was developed at the Mormon university BYU where they are big into tracing their ancestry. This worked for a industrial applications because to correctly order these codes the user need to be able to build something like a database and have a way of relating the contents. But this was done before databases had been formalized.
So, please be kind to a newbie and give me some sage advice on the best way to approach this.
Thanks
Noah
|
|
|
|
|
Maybe you should post this in the General Database Forum - you will get better replies there.
I don't speak Idiot - please talk slowly and clearly
'This space for rent'
Driven to the arms of Heineken by the wife
|
|
|
|
|
I am not sure if the answer will be small enough to discuss in the forum. Still, you should give a try in the database forum.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
You're new to programming and want to replace a complex historic bunch of code?
I suggest you use the Job Board and look for a professional to solve your problem.
|
|
|
|
|
You've come to a point in the road where the question is "Should I build a system to meet my requirements or Buy an already designed/tested/supported ?"
You may want to invetigate systems that will meet your need and weigh that against the cost of developing a new system. If nothing else, you will see how other people have solved the problem an maybe give you an idea on how to start your design.
However, I've done some work for manufacturing companies in the past from what I can remember, I think you want to start your analysis/design by thinking of the "big" blocks of your application, then gradually add more and more detail to each block and show the relationships among the blocks.
Some of the "blocks" I can think of are:
Customer
Parts
Instructions
WorkOrder
WorkOrderDetail
Research Entity-Relationship Diagrams to help you organize your design ...
http://en.wikipedia.org/wiki/Entity-relationship_model[^]
Visio is a cool tool to map things out ...
|
|
|
|
|
is it possible to embed the "classic" (XP and older) Windows Explorer control in a MS Access form (Access 2007 running on XP, ...)?
What I want is the folder view that appears on the left side of Windows Explorer (complete with icons) and the file view that appears on the right side (simple Detail view would be ok.)
So, is it possible to get these two views and control it in MS Access form? If not, do I have to do this separately? Can I get the file-associated icons without any work?
Thanks for advice!
Johnny John John
|
|
|
|
|
I'd research whether the WebBrowser control could be referenced from Access, and let it navigate to a local path.
I are Troll
|
|
|
|
|
Hello!
I've got a strange problem with the following piece of code:
Public Sub NodeDispl()
Dim objOpenSTAAD
Dim nNodeNo As Integer
Dim nLC As Integer
Dim pdDisps(6) As Double
Set objOpenSTAAD = CreateObject("OpenSTAAD.Output.1")
objOpenSTAAD.SelectSTAADFile "C:\temp\staadtest.std"
objOpenSTAAD.GetNodeDisplacements 7, 101, pdDisps(0)
objOpenSTAAD.CloseSTAADFile
Set objOpenSTAAD = Nothing
End Sub
The code above is used to read the results from a structural analysis program and works fine in VBA using Excel. The results are stored in the variable pdDisps, which is an array.
However, I'm trying to make a stand-alone application using Visual Basic (2008 Express Edition). When inserting a similar piece of code in VB, only the first value is read - instead of an array of values I get one value and the rest of the elements in the array are zero.
1. Is there any logical explanation for this behaviour?
2. If not, is there a way I can implement VBA code into my VB application?
|
|
|
|
|
What does your VB.NET code look like?
|
|
|
|
|
I knew I forgot something....
Here is the similar section of code in VB.net:
Public Sub NodeDispl()
Dim pdDisps(5) As Double
Dim ObjOpenSTAAD = CreateObject("OpenSTAAD.Output.1")
ObjOpenSTAAD.SelectSTAADFile("C:\temp\staadtest.std")
ObjOpenSTAAD.GetNodeDisplacements(7, 101, pdDisps(0))
ObjOpenSTAAD.CloseSTAADFile()
ObjOpenSTAAD = Nothing
End Sub
|
|
|
|
|
OK, since OpenSTAAS is a COM object, I suggest ditching the late binding you're using now and go for early binding instead. Open the project propties and click on the References tab. Add a COM reference for your library (it'll show up in the list somewhere) and in your code, rewrite to this:
Public Sub NodeDispl()
Dim pdDisps(5) As Double
Dim objOpenSTAAD As New OpenSTAAD.Output
objOpenSTAAD.SelectSTAADFile("C:\temp\staadtext.std")
objOpenSTAAD.GetNodeDisplacements(7, 101, pdDisps)
objOpenSTAAD.CloseSTAASFile()
End Sub
The code may not as written, but it'll be close.
|
|
|
|
|
Thanks a lot! Now it all works like expected.
It was as I suspected; a trivial solution to the problem. However, I'm quite new to programming and wasn't even aware of the concept of early/late binding. However, in the example I copied (written in VBA), late binding was used. Just out of curiousity - is there a reason why this is used at all?
|
|
|
|
|
Yes. Sometimes you can use different versions of an object and you don't know which one(s) is/are installed. Since early binding is a bit "version" dependant, if the correct version isn't installed when you run the app, every though some version of the component is installed, your app will fail.
|
|
|
|
|
Hi,
I've run into a major problem. As described earlier, I couldn't figure out how to make my code work in vb.NET, when it worked fine in VBA. That problem was resolved and everything has worked fine until yesterday when suddenly everything stopped working. I think I've managed to isolate the problem, but cannot figure out why it occurs:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles Button2.Click
Dim Analysis As New OPENSTAADLib.Output
Dim nLC As Integer = 0
Analysis.SelectSTAADFile("c:\temp\PSDesigner\PS-1_Operation.std")
Analysis.AnalyzeStructure("NORWAY")
Analysis.GetLoadCombinationCaseCount(nLC)
MsgBox(nLC)
End Sub
Short explanation:
OPENSTAADLib is an external COM component which I had to reference in order to access. The OPENSTAADLib.Output object is used to run an input file for a structural analysis. The "AnalyzeStructure" command is the actual analysis, whereas the GetLoadCombinationsCaseCount is an example of a function to retrieve information from the results of the analysis.
- Now I get this error message: "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
- I tried putting the functions inside Try blocks, and made them loop back a number of times in order to retry. That helped a little, but it seems to be all random whether it works or not.
- when I start the debugging, I can run the sub once or even twice without problems, but then it won't work any longer.
The exception message says: "External component has thrown an exception". I also have seen the System out of memory exception, even though (according to the windows task manager) the program does not use a lot of resources.
I am still a quite unexperienced programmer and I really don't know how to resolve this or even where to begin look for answers (except her on codeproject, of course).Sondre M
|
|
|
|
|
I know nothing of your component, so I can only guess.
The first thing I'd check would be the validity of the PS-1_Operation.std file.
Next, I'd open Task Manager, turn on some addition columns, like Handles, Threads, User Objects, Memory Peak Working Set, Cand Commit Size. Then I'd watch the app run again, watching those numbers. You CAN run the machine "out of memory" by leaking things like Handles.
I'd also throw the app at a profilers, like ANTS.
It's possible that you're not freeing up or releasing this component properly.
|
|
|
|
|
The file applied is definetely valid. The .std is really only a textfile which I have no problem running using the GUI of the analysis program (STAAD.Pro).
I will try and look more closely into the Task Manager although I'm not quite sure what to look for.
Earlier today I opened up a backup copy of the code from last month, hoping that it would still work, but even if it worked better than the latest version, eventually it too failed. The reason why it failed now and not earlier may be that the program haven't been tested for any long "sessions" - until now. This seems to be the problem.
My prime suspect was really something memory related, which would probably explain why the program failed afted a while (after several runs of the analysis). But then I started a blank VB project with the few lines of code as displayed in the previous post, and it failed at once.
How can I make sure that I free up or release the component?
|
|
|
|
|
Only the docs on the component are going to tell you that.
If it failed the first time you ran a small test app, it's probably not going to be resource related. It's probably going to be something wrong with the component itself. If that's the case, there's nothing you can do about it, short of seeing if there is an upgraded version available.
|
|
|
|
|
|
Not really true. You can still install and use the VB6 runtime on Windows 7, even SP1. It doesn't have to ship with Windows 7 in order to work. Windows 7 still has support built into it to keep the VB6 runtime working.
All support to use the VB6 runtime, and therefore run any VB6 app, will end with Windows 7. That means, when Windows 8 shows up, your VB6 app will no longer work at all.
Frankly, IMHO, there is no excuse for continuing to use VB6 as a development platform. All existing applications that still need to be used should be rewritten using C# or VB.NET.
|
|
|
|