|
The majority of databases are relational types. What you need to find out is what software product is used to create it: Oracle, SQLServer, MySQL, SQLite etc.
|
|
|
|
|
Ok, so Azure supports a wide range of databases.
|
|
|
|
|
This has nothing to do with Azure. If you want to access a database then, as I already suggested, you need to know what type of database (i.e. which product is used to manage it). And the quickest way to find that answer is to talk to the people who own it.
|
|
|
|
|
|
OK, so you need to install SQL client on your system, and get the details of the database structure from the people who own it.
|
|
|
|
|
Is there no shortcut available? I'm open to using hacks.
|
|
|
|
|
I'd recommend you to install SSMS (SQL Server Management Studio) instead.
|
|
|
|
|
Are we to assume that you do not actually have permission to access this database?
|
|
|
|
|
No, I have access. Since this software will be run on other computers than my own, I'd like to keep 3rd party software installations/dependencies to a minimum. Ideally, all you'd have to do to run my application is to double-click an .exe-file (ideally, you should also be able to run it from a USB-stick), I don't want anybody to have to do anything more. That's why I don't use installers and instead embed all my dll:s and icons/pictures into my .exe-file, I don't like to give installation support, especially not on something I didn't write myself.
|
|
|
|
|
Well at the risk of repeating myself yet again: go and talk to the owners of the database to find out what client software you need to install, and what the schema structure is. They are the only people who can provide this information.
|
|
|
|
|
Wait you already have an application that will consume the data!
Why don't you modify your app to query the database?
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
No, I'm about to start writing an application.
|
|
|
|
|
Then write the database query into your application like every other developer does.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
It just occurred to me that the answer to this is quite simple. Go and talk to the people who own the database, they will be able to tell you exactly which client libraries you need.
|
|
|
|
|
arnold_w wrote: I am writing a C# application in Visual Studio 2005 and I
2005 is rather old and I suspect that might be a problem.
But maybe you meant 2015.
For a database application you need
1. Access permission to the database. This includes a connection path and user permissions. This is information not code.
2. A connection library for the database. This a library.
3. Probably a framework that will use the connection library.
4. Then you use 3 to get data from the database where you have provided 1 to 2.
arnold_w wrote: There is no requirement that I should access the data I want through SQL-queri
That is unlikely unless the database is a No-SQL database.
|
|
|
|
|
I found a really great tool where I can browse for an .mdf-file and select it and then see the tables with all the data. It's called "SysInfoTools SQL File Viewer v18.0" and it's only a few megabytes large. After I have installed it, I can see a file called "Script Instruction.txt" in the installation folder with the following contents:
"**********************************************************************
Information about script
**********************************************************************
Mainsqlscript.bat is our main script File, which contains path information of all the tables, views, stored procedure, triggers, functions,etc.
Script file with database name “Databasename”.sql File contains script for creation of Database.
Tables Folder Contain Script of all the tables.
StoreProcedure Folder Contain script file for every Procedure.
Triggers Folder Contain script file for every Trigger.
Views Folder Contain script file for every view.
Functions Folder Contain script file for every function.
altertablecommandPrimarykeys contain script file for every primarykey.
Altertablecommandforeignkeys contain script file for every foreign key.
**********************************************************************
How to run Script
**********************************************************************
1. Open Command prompt. Cmd.exe with run as Administrator.
2. Move to Batch file path using command cd "Path of batch file"
3. Type Command
mainsqlscript.bat <username> <password> <server name=""> <database name="">
NOTE: If the given Database name already exist in sql server instance then old database will be deleted and new database with the given name is created.
Server Name and Database Name are compulsary parameters for running script."
Does anybody understand what they mean by the above, does it mean that I can run it from a standard .bat-file (the ones that were invented by Microsoft in the 80's) and not have to see the GUI show up?
|
|
|
|
|
Ok, here is the code in my class
static public DataTable query_search(string sqlite_query, SQLiteParameter[] parameters)
{
SQLiteConnection sqlite_conn = new SQLiteConnection("Data Source=test.db;Version=3;Compress=True;Synchronous=Full;");
sqlite_conn.Open();
SQLiteCommand sqlite_cmd;
sqlite_cmd = sqlite_conn.CreateCommand();
sqlite_cmd.CommandText = sqlite_query;
SQLiteDataReader sqlite_datareader;
sqlite_cmd.Parameters.AddRange(parameters);
sqlite_datareader = sqlite_cmd.ExecuteReader();
DataTable returnTable = new DataTable();
returnTable.Load(sqlite_datareader);
writedebug(returnTable.Rows.Count.ToString());
sqlite_conn.Close();
sqlite_datareader.Close();
return returnTable;
}
writedebug writes 0 rows
My call
private void button1_Click(object sender, EventArgs e)
{
if (search.Text.Trim() != "")
{
SQLiteParameter[] param = {
new SQLiteParameter("%@search%", "paul")
};
customerList.Rows.Clear();
DataTable searchinfo = database.query_search("SELECT id, firstname, lastname FROM customers WHERE firstname LIKE '@search' OR lastname LIKE '@search'", param);
MessageBox.Show(searchinfo.Rows.Count.ToString());
foreach (DataRow row in searchinfo.Rows)
{
customerList.Rows.Add(row[0].ToString(), row[1].ToString() + " " + row[2].ToString());
}
}
}
if I replace @search in the query with "%paul%" (in the database) writedebug turns 2 and it adds the rows to the form table
I can query and put the search.Text directly into the string like SELECT id, firstname, lastname FROM customers WHERE firstname LIKE '" + search.Text + "' OR lastname LIKE '" + search.Text + '" but I needed sanitized queries (even though im the only one using this software), adding a % will make it return all rows
I've used SQLiteParameter for INSERT INTO with another function successfully. please help
thanks
|
|
|
|
|
You cannot use "%@search% as the parameter name, as it is not a valid name. Try something like:
string psearch = "%" + search + "%";
SQLiteParameter[] param = {
new SQLiteParameter("search", psearch)
};
Then use "@search" in the SELECT clause as the parameter reference.
NB the actual syntax of the command may not be exact.
|
|
|
|
|
tried and failed.
wait, using it without ' in the query string works. yes, thank you
though I can still input % as a wildcard and get all rows. I thought this supposed to sanitize/escape input. guess I can live with it though, unless you have a better idea
|
|
|
|
|
Yes, because parameter names must be entered 'as is', not quoted.
|
|
|
|
|
do you know why the % char isnt being escaped?
|
|
|
|
|
Not sure what you mean, I thought is was the wildcard character for the LIKE phrase.
|
|
|
|
|
yes, but if it's put into the textbox, it's queried as LIKE %%% which matches everything
|
|
|
|
|
I'm sorry, you have lost me. What has a TextBox got to do with SQL statements?
|
|
|
|
|
it's a search query for a database, text input box
|
|
|
|