Hi using VS 2022 fresh install, new project i keep getting a file named XXX already exist, ive tried restaarting vs, checking solution explorer for hidden files, unloiading and reloading the project and even cleaed my temp folder
before adding new item
After selecting item to add is same with any item i select
Related
I have a data table (Named "Effects") from Access in my VB.Net Userform.
I have two buttons (AddEffect.Click and SaveEffect.Click) that use ADD NEW, END EDIT and UPDATEALL. This works whilst the app is open.
A new record appears in the GRIDVIEW with the Data I inputed into the various textboxes.
Private Sub AddEffect_Click(sender As Object, e As EventArgs) Handles AddEffect.Click
Me.EffectsBindingSource.AddNew()
End Sub
Private Sub SaveEffect_Click(sender As Object, e As EventArgs) Handles SaveEffect.Click
Me.EffectsBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.DatabaseDataSet)
End Sub
However, there are two issues.
The ID Number of the New Record generated is always a -ve integer.
When I click the SAVE ENTRY button and restart the application, the changes have not been saved.
Other examples I look at online do not resemble my issue.
EDIT:
The ID Number of the New Record generated is always a -ve integer.
That's exactly as it should be. The value generated by your application is only temporary. The final ID is generated by the database when you save. The temp value is negative to ensure that it doesn't clash with anything that's already in the database.
When I click the SAVE ENTRY button and restart the application, the changes have not been saved.
You are almost certainly over-writing your database. The way file-based databases should work is that you add a source file to your project and that gets copied to the output folder along with your EXE. It's that copy that your app connects to while you're debugging. If you create a new copy the next time you build, which is the default, you lose any changes you made to the old copy.
To avoid that, select your data file in the Solution Explorer, open the Properties window and set Copy to output directory to Copy if newer. That way, a new copy will only be created if you explicitly delete the old copy or make a change to the source file.
The reason for the dual-file approach is that you're supposed to keep your source file clean and free of test data so that the copy created when you build a Release version of your app will be ready to deploy with a fresh app.
need to ask, I have simple app, which had one textbox and one button. When I type something to that textbox and push that button, it saves to my Settings...
see:
Dim Settings As New My.MySettings
Settings.something = TextBox2.Text
Settings.Save()
MessageBox.Show(Settings.something.ToString)
Everything works great, but when I build it and run for example from my desktop path, Enter number save it and close it. When I make a copy of this file to my documents path and open it, nothing loaded, but when I start it from the place where I last save it, it loads properly.
In the short description:
If I run app on my Desktop path and make a save, when I close the app and copy this file (.exe) to another path, I need to load previous saved data from Desktop path, or other different location.
Save in path A, copy it from and open anywhere in path B, C, D... etc.
Is it possible, if yes, how can I do that?
Thanks!
You may be looking for something like the 'SaveSetting" method
SaveSetting("MyApp", "Form1", "Text", "ValueToSave")
The first, second and third parameters indicate a "Path" where your value will be saved, and the fourth is the value itself.
Then, you can load the saved value using the following method:
MyText = GetSetting("MyApp", "Form1", "Text", "DefaultValue")
Note that the first three parameters must be the same as used on the save method, and the fourth is the default value, in case no previous data has been saved.
I am working on a project where I have created a PowerPoint addin. The concept is this will only contain an user form, with a list box. Based on the user selection other modules (bas files) will be added or imported to the presentation and the code will be executed.
I don't want to include all the modules in the add in as depending upon the requirement I can do the modification and then can store in a shared folder. So every time user uses the addin they can have the updated version. So I don't have to re circulate the addin with every change.
I have a blank module where i import the code from a text file (code from bas file saved as text) and it runs.
I can import the bas files, also using inserFrom file option I can import code from a text file, but problem is it's always getting added to the current presentation code window. But I want to add the code to the addin code pane.
I have a blank module in the addin called "tempCode", where I want to update the imported code, but I am not able to do so.
It works fine when I am editing the addin as a ppt, but when I convert ppt to an addin the concept is not working.
Any ideas how I can add the code to the addin code pane rather adding to the active ppt.
Code details:
I have a user form, with a list box.
It has 3 items.
Option 1
Option 2
Option 3
If user selects any option, let's say option 2, the code for option 2 will be imported from a text file to the working module.
And a command button to run the selected.
Name of working module is “Mod_Working”
Name of text file is “C:\Code\Option2.txt”
Below is the code I am using:
Sub ImportSelected()
With ActivePresentation.VBProject.VBComponents(“Mod_Working”).CodeModule
.DeleteLines 1, .CountOfLines 'it deletes any existing code
.AddFromFile “C:\Code\Option2.txt”
End With
End Sub
Code in text file:
Sub Test
Msgbox “You selected Opt 2”
End sub
Code of Command Button:
Private Sub Cmd_run_Click()
Application.Run “Mod_Working.Test”
End Sub
This works in ppt mode but not when converted to addin.
Why not do this:
- In the shared folder, mark the add-in file as read-only (right-click, properties). This prevents the file being in-use when people are using the add-in (at least it works that way in Excel)
- When you have an update, simply replace the add-in and set it to read-only again.
Alternatively, check out: www.jkp-ads.com/articles/updateanaddin.asp
Am working on creating SSIS Package the does the following, so far my SSIS Package works well to insert records from '.DBF' file from one folder location ONLY (Am using Data Flow Task onto the Control Flow and OLE DB Source/Destination to read a .DBF file and get it inserted). However, am not able to figure out how to make it works with 20 sites, for example: I have 20 '.DBF' files stored in the following structure:
1. E:\DBF Files\Site1\Data\records.DBF
2. E:\DBF Files\Site2\Data\records.DBF
3. E:\DBF Files\Site3\Data\records.DBF
4. E:\DBF Files\Site4\Data\records.DBF
and so on till Site20 (here file name remain the same but the content will differ from site to another).
I have table for 'records.dbf' file in my SQL Server in the following structure:
Records Table:
Product_Name Price FilePath FileName
---------------------------------------------------------------
now here, how can process these files from different sites to be stored in my records sql table with it respective FilePath using SSIS??
P.S File Names will always remain the same and the path will change "Like Site 1"
Grab a For Each Loop container for the SSIS Toolbox and drag it on to the Control Flow designer.
Double click the For Each container to bring up the editor, click the Collection tab from the left-hand menu
Leave the Enumerator set at Foreach Item Enumerator and click the Columns button in the lower right.
Click the Add button and just go with the defaults which should be Column 0 and String. Click OK to return to the previous dialog. In the new Column 0 column add your folder paths one per row.
Next click the Variable Mappings tab from the left-hand menu, for the drop-down menu in the Variable column select New Variable. Again go with the defaults except for the name which in my example I have called dbf_path.
Next click OK to complete the For Each. Now the difficult bit for me because I don't what tasks you currently have that are working for one file. Whatever it is you have working, select it with the mouse and then drag and drop it into the For Each container.
For each task or tasks that need to use the file path do the following:
double click it to edit, in the left-hand menu select Expressions, then click Expressions and then click the ellipsis.
From the Property drop-down in the Property Expression Editor you need to find the property that would hold the file path for this task. The names are not always obvious and can be called different things in different tasks. In my example I am using a File System Task which I think is the Source Property.
Click the ellipsis in the Expression column and add an expression that consists of your path variable concatenated a string that contains the name of your file. One thing to note is backslashes have special meanings so if your string contains any they must be escaped with a second backslash.
Now when you run the package the For Each will loop through each path you have defined and store it in your variable which tasks will reference.
In my VB.net project I created a custom cursor (Window.cur). How can I assign that to the cursor without having to use the full file path to that file?
VB.Net has My.Resources but it does not show the cursors that are embedded in the project.
I found an example that used code like this:
New Cursor(Reflection.Assembly.GetExecutingAssembly.GetManifestResourceStream("Window.cur")
but that does not work.
Guessing the resource name can be difficult. To find out, run Ildasm.exe on your program. Double-click "Manifest" and look for the .mresource.
Another way to do it that avoids guessing: Project + Properties, Resource tab. Click the arrow on the "Add Resource" button, Add Existing File and select your .cur file. Make your code look like this:
Dim ms As New System.IO.MemoryStream(My.Resources.Cursor1)
Button1.Cursor = New Cursor(ms)
Thanks for the help! I assumed that if I created the resource in the Visual Studio IDE it would add it to my project. Silly me!
I had to go to the Project tab to add the Window.Cur file using Add Resource (thanks nobugz!) and then use the code he mentioned:
Dim ms As New System.IO.MemoryStream(My.Resources.Window)
Button.Cursor = New Cursor(ms)
Suppose you are assigning "Cursor1.cur" to be the cursor for the control "Button1."
In your Form.Load event you would do something like -
Button1.Cursor = New Cursor(Me.GetType(), "Cursor1.cur")
You are missing the namespace. You probably want to use:
MyNamespace.MySubfolder.Window.cur
EDIT: Also, make sure your Build Action for the item is "Embedded Resource", otherwise it will not be include in your dll/exe.