I'm getting closer to having a functional SQLite Database in my Universal App.
I keep getting the error 'Cannot Open' and I feel it might be a path problem as SQL Toolbox for Visual Studio picks up the .db file fine.
How to I reference the .db should i put it in a new folder? I need to perform operations to this database but information on this in VB.NET is extremely limited!
Here is what I have so far:
Dim platform As New SQLite.Net.Platform.WinRT.SQLitePlatformWinRT
Dim lc As New SQLite.Net.SQLiteConnection(platform, "/myDB.db")
lc.Execute("INSERT INTO lcCust (CName) VALUES ('Hello')")
I have now successfully created a db using a GUI program. This one specify is SQLiteStudio. I created the DB and connected to it using the SQLite-PCL package along with the Visual Studio addon
Related
I am exploring methods to enable users to restore a database from within the project.
I have a project which I want to publish together with the database, so that users with no experience can use the program I have developed.
The code is written in VB script and I am able to publish the VB code, but am finding it difficult to include the database in the ClickOnce method.
I have been thinking that I could possibly copy the .bak file to the client's PC and then run a VB script that restores the database to the SQLserver that is installed in the ClickOnce install.
Has anyone ever done this?
I did find on the web something that looked promising, but it has been written for .NET framework 2.0 or 3.0 and I found that when I added System.Data.SqlClient 4.8.0 I got the following error:
Severity Code Description Project File Line Suppression State
Error Could not install package 'System.Data.SqlClient 4.8.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v2.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
The website where I got the code: http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=1433&lngWId=10
Please can anyone help?
VBScript, which would get run via wscript.exe is decades old technology
VB.NET, which would get compiled into a custom .exe or .dll, is 2005+ (not included in this is .net core which is the past few years but I've not touched it)
dim connectionString as string = "Provider=MSOLEDBSQL;Server=localhost;Database=myDataBase;Trusted_Connection=yes;"
dim connection as New OleDbConnection(connectionString)
Dim cmd As New OleDbCommand
Dim query As String = "RESTORE DATABASE AdventureWorks2012 FROM AdventureWorksBackups;"
Try
cmd.CommandText = query
cmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox("something bad happened")
End Try
Reference bits
ExecuteNonQuery https://learn.microsoft.com/en-us/dotnet/api/system.data.oledb.oledbcommand.executenonquery?view=netframework-4.8
Restore database https://learn.microsoft.com/en-us/sql/t-sql/statements/restore-statements-transact-sql?view=sql-server-ver15
and if you're not using OLEDB, or need a different provider, then futz with connection string as needed but that's the general approach
I am working on an app in VS which includes a SQL database stored locally on my C drive. I can publish the app and it works fine on my own computer, but because the database is stored locally, I cannot run the app from any other computer (SQL exception 52). I would like to move the app to a network drive so it can be accessed by multiple users.
I have tried to move the database by changing the default database location in the SQL server object explorer. I’m wondering if I should have SQL server express LocalDB installed?
I have no programming training but have been dumped with this project at work as I have used VBA before, so I’m sorry if this question it stupid. I would really appreciate it if someone could point me in the right direction!
When accessing your database, rather than using just the database name, you should specify the filepath aswell, like this:
Public Filename As String = $"[**FilePath**]ActiveFitness.accdb"
This tells the programme where to look for the database, and is better practice than relying on the default location.
Not sure why the Query and View Designer is not appearing as per
http://msdn.microsoft.com/en-us/library/vstudio/ms172013.aspx
It's an ASP.net project with database in the AppData folder, and a connection using SQL 2008 Express.
If it helps the connection string is:
Data Source=.\SQLEXPRESS;AttachDbFilename="C:\folders...\App_Data\database.mdf";Integrated Security=True;Connect Timeout=30;User Instance=True
If I open the project in VS2012 (where I've worked on this project for some time), find a table, right click, new query, I get the nice interactive visual design tool.
If I open the project in VS2013 (just installed) and do the same, blank page named SQLQuery1.sql and a basic connection to SQL Express (ie. master, model, etc.)
MS page tells me Tools / Options / Visual Database tools - but this doesn't exist on my installation!
Am I missing something?
Also tried with blank project, added App_Data and a new database (so using LocalDB), added a table, right click, new query - exactly the same blank file.
I have been having the same problem and think I have found the solution.
When you are adding the connection to the Database, in the Add Connection Dialog.
Click 'Change...' next to the Data source
Dialog opens showing 'Change Data Source'
You probable have selected 'Microsoft SQL Server' and then below that there is a drop down where you can select:
.NET Framework Data Provider for OLE DB
.NET Framework Data Provider for SQL Server (This is probably selected by default)
try changing to the OLE DB connection.
Click OK, and then complete the rest of the connection on the 'Add Connection' dialog.
I have then found that using the database works as it did in VS2012 and as you are describing above.
Was searching for a solution to a similar issue. Unable to use Query Designer for a local mdf file database. This is what I found...hope it helps someone.
Reading the comments here (http://social.msdn.microsoft.com/Forums/sqlserver/en-US/ed4675d3-aa84-47db-bdf5-f852355409e6/query-designer-not-displaying-in-visual-studio-2013?forum=ssdt).
According to the moderator of that forum question (Kevin Cunnane of Microsoft), "in Visual Studio 2013 the query designer and database diagram features are no longer available from the Server Explorer. If you wish to keep using the query designer, the only other workaround for now is to access it from SSMS. "
My current workaround is to use Visual Studio 2012 Server Explorer to view data and write queries for a local MDF file. And to use Visual Studio 2013 for everything else.
I have researched about 5 minutes how to run a query in Visual Studio. At the end I found this:
Even though i followed same steps , It did not work at once it gave some error and Studio closed. It was problem at my end and unknowingly it got sorted out on its own.
This component is called "SQL Server Data Tools". You can download it from MSDN. I found this page simply by googling "vs2013 ssdt". It seems that what TsugaSoft posted is true, however you still can install this component separetely... And it also works for Visual Studio 2012.
I'm fairly newb when it comes to programming and even newer when it comes to database management and integration.
So I have a VB.NET Windows Application that uses a SQL Database. I use LINQ to SQL to fill datagridviews in windows that show table data and also use LINQ to SQL to save data to the database.
All works wonderfully however...
When I publish the application, the database isn't external as far as I can tell. It seems to build itself into the application so once the application is installed, the database is there, it views and saves data, but if the computer crashes or the application is uninstalled, all that data is going to be lost without a way to back it up.
I'm using Visual Studio 2010 Express. I created the SQL Database in VS2010-Exp as well. I feel like there's something simple I'm missing here. When the application gets published and then installed, where is the physical database going?
Thanks!
It is running as part of the application. If you wanted a separate, central database, you would need to have an instance of SQL server running in some accessible location.
Good evening/morning/after/noon.
I have an ASP.net 3.5 website and I am using vb.net in VWD 2008 Express, I am also using MS SQL Server 2008 Express, I used ajax tabs and a textBox charavters counter control develped by https://web.archive.org/web/20211020202742/https://www.4guysfromrolla.com/
The database is attached with MS SQL Server Management Studio Express and the files are stored in the SQL default "Data" folder.
The whole project's code and forms are stored in a folder in my E drive.
I need to hand the whole project to another coworker who have to finish it, please describe in steps how can i make my website portable (like i can put it all in a folder that he can carry around in his flash disk).
PS: I have had a problem trying to move the project from one server to the other, the pproject seems to look for the dlls of the AJAX control and the textBox counter where i originally unzipped the folders in which they cam in, which i think was on my desktop, although when i added those controls to the Tools tab, i created a new tab, then i choose the dll from the where i unzipped the controls source code, aint that enough?
Thanks in advance
When you create the structure, make a folder for referenced files in the source tree. You can then reference from there. If you do that the entire tree is portable. The only changes, from environ, to environ, are configuration elements. And, if on the local system, you use SQL Express and put in the App_Data folder, it cana connect to your coworkers system, as long as he also has SQL Express.