|
can anyone guide on what's the best way to create my own database using binary files and C#?
|
|
|
|
|
Um. Don't?
To be honest, unless you are doing something really small and trivial, the work involved is going to be ridiculous for the reward you will get. Just working out the record locking if it is to be multi-user will be pretty horrible. Then there is the space allocation, the different variable storage requirements, and so forth.
If you just need to store single user values, then go with XML or SOAP.
If you need to store multi-user data, or delete / insert records, then use SQLExpress or MySQL - both are free and will be a lot less hassle to get working and debugged.
I have learnt that you can not make someone love you, all you can do is stalk them and hope they panic and give in.
Apathy Error: Don't bother striking any key.
|
|
|
|
|
Don't try. If you just need to store something, just do it but don't call it a database. If you need a database, use a database, if you make one yourself it will just have a ton of bugs..
And "binary file" is a pleonasm. All files are binary. Just, some binary files are also something else (a text file is also a binary file, etc). I'm sure you know that, but it looked suspicious.
If the point is just trying to make a database just for the heck of it, that's nice, I'd start by reading the relevant articles on wikipedia
|
|
|
|
|
hi,
i've made a relational DBMS (database management system) for smart devices for my college diploma, based on binary files and XML.
In the XML it describes the structure of the database then the data will be written in binary files, and the search is based on indexing each column (the indexing algorithm is based on hashtables).
I've worked very hard and for long time to acomplish what is allready done with succes and no headaches by Microsoft or Sun.
Conclusion: The job is a little too much for 1 programmer and not worth the effort.. i was very stubborn to do this.
See this: [DBMS Wiki] and [RDBMS].
|
|
|
|
|
Hi everybody,
I am trying a smart device application.
the problem is after i execute a querry that should insert a new line in a table, i go to check if the line existe really in the table then i don't find it.
this is the code i used.
Thank you for your help in advance.
private void menuItem4_Click(object sender, EventArgs e)
{
string wCS = @"Data Source =\Storage Card\ModeDifféré\BaseGmaoLocale.sdf;";
SqlCeConnection sqlceconn = new SqlCeConnection(wCS);
SqlCeCommand command2 = sqlceconn.CreateCommand();
command2.CommandText = "INSERT INTO compteurs2 ([com], [quantite],[datequantite] ) Values(@com,@qtte,SYSDATE)";
command2.ExecuteNonQuery();
SqlCeParameter com = new SqlCeParameter("@com", SqlDbType.NVarChar);
com.Value = comComboBox.SelectedItem.ToString();
command2.Parameters.Add(com);
SqlCeParameter qtte = new SqlCeParameter("@qtte", SqlDbType.Float);
qtte.Value = float.Parse(textBox1.Text);
command2.Parameters.Add(qtte);
}
|
|
|
|
|
I think you should execute the command afther you add the parameters to it, or else the insert will fail (as it has so far) havning nothing to insert.
Something like this:
private void menuItem4_Click(object sender, EventArgs e) {
string wCS = @"Data Source =\Storage Card\ModeDifféré\BaseGmaoLocale.sdf;";
SqlCeConnection sqlceconn = new SqlCeConnection(wCS);
SqlCeCommand command2 = sqlceconn.CreateCommand();
command2.CommandText = "INSERT INTO compteurs2 ([com], [quantite],[datequantite] ) Values(@com,@qtte,SYSDATE)";
SqlCeParameter com = new SqlCeParameter("@com", SqlDbType.NVarChar);
com.Value = comComboBox.SelectedItem.ToString();
command2.Parameters.Add(com);
SqlCeParameter qtte = new SqlCeParameter("@qtte", SqlDbType.Float);
qtte.Value = float.Parse(textBox1.Text);
command2.Parameters.Add(qtte);
command2.ExecuteNonQuery();
}
Oh and, I an not 100% sure, but I think that SYSDATE is not supported in SQL CE, the one that should work is GETDATE() .
I have no smart signature yet...
|
|
|
|
|
thank you for your suggestion but it still doesn't work.
|
|
|
|
|
What is the code you run now and what si the result (any exceptions?).
I have no smart signature yet...
|
|
|
|
|
this is the code:
private void menuItem4_Click(object sender, EventArgs e)
{
DateTime t = DateTime.Now;
string wCS = @"Data Source =\Storage Card\ModeDifféré\BaseGmaoLocale.sdf;";
SqlCeConnection sqlceconn = new SqlCeConnection(wCS);
SqlCeCommand command2 = sqlceconn.CreateCommand();
command2.CommandText = "INSERT INTO compteurs2 ([com], [quantite],[datequantite] ) Values(@com,@qtte,@dat)";
SqlCeParameter com = new SqlCeParameter("@com", SqlDbType.NVarChar);
com.Value = comComboBox.SelectedItem.ToString();
command2.Parameters.Add(com);
SqlCeParameter qtte = new SqlCeParameter("@qtte", SqlDbType.Float);
qtte.Value = float.Parse(textBox1.Text);
command2.Parameters.Add(com);
SqlCeParameter dat = new SqlCeParameter("@dat", SqlDbType.Float);
dat.Value = t;
command2.Parameters.Add(dat);
command2.ExecuteNonQuery();
}
and i didn't see any exception.
|
|
|
|
|
I think that:
a) you connection is not opened
b) yout command is not attached to that connection
c) adding twice the com parameter does not solve anything
d) the @dat parameter should by datetime
Most probably this code should work:
private void menuItem4_Click(object sender, EventArgs e)
{
string wCS = @"Data Source =\Storage Card\ModeDifféré\BaseGmaoLocale.sdf;";
using(SqlCeConnection sqlceconn = new SqlCeConnection(wCS))
{
string insertString = "INSERT INTO compteurs2 ([com], [quantite],[datequantite] ) Values(@com,@qtte,@dat)";
SqlCeCommand command2 = sqlceconn.CreateCommand(insertString, sqlceconn);
SqlCeParameter com = new SqlCeParameter("@com", SqlDbType.NVarChar);
SqlCeParameter qtte = new SqlCeParameter("@qtte", SqlDbType.Float);
SqlCeParameter dat = new SqlCeParameter("@dat", SqlDbType.DateTime);
com.Value = comComboBox.SelectedItem.ToString();
qtte.Value = float.Parse(textBox1.Text);
dat.Value = DateTime.Now;
command2.Parameters.Add(com);
command2.Parameters.Add(qtte);
command2.Parameters.Add(dat);
command2.Connection.Open();
command2.ExecuteNonQuery();
}
}
I have no smart signature yet...
|
|
|
|
|
thank you but for the line:
SqlCeCommand command2 = sqlceconn.CreateCommand(insertString,sqlceconn);
the following error occurs:
Error 1 No overload for method 'CreateCommand' takes '2' arguments C:\Users\Admin\Documents\Visual Studio 2008\Projects\GMAOMobile\ModeDifféré\Energie.cs 107 41 ModeDifféré
what is the problem?
|
|
|
|
|
My bad, try
SqlCeCommand command2 = sqlceconn.CreateCommand();
command2.CommandText = insertString;
or
SqlCeCommand command2 = new SqlCeCommand(insertString,sqlceconn);
Both do the same thing.
I have no smart signature yet...
|
|
|
|
|
the error was repaired but nothing happened in data base. There is is no line inserted.
|
|
|
|
|
How do you check if your line has been inserted?
I have no smart signature yet...
|
|
|
|
|
i open the table from visual studio after closing the application and i check if there is a new line inserted.
|
|
|
|
|
Most probably the table opened from visual studio is just a local copy of the database file.
Your operation is made on the smart device simulator, on that database. You can download the file from the smart device and check the row is inserted, or you can execute a select command on the device to check the row count.
I have no smart signature yet...
|
|
|
|
|
|
Sr...Frank wrote: Please let me know right code.
By this you mean, write code for me. No. You have a list of the child windows, iterate through them and close.
If you have tried and need help, then post what you have tried and ask.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
private void button2_Click(object sender, EventArgs e)
{
foreach (Form2 f in this.MdiChildren)
{
f.Dispose();
}
}
|
|
|
|
|
|
please don't remove messages, it is against the forum guidelines.
|
|
|
|
|
Please don't feed the idiots.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi Guys,
I wish for the first line of my DataGridView to be a search line, meaning that all the other rows are filtered according to the value the user inserts to the corresponding column top cell. For example, if the user enters "a*" at the first row's first cell, only rows with the first cell beginning with the letter "a" are shown. Of course, when sorting, this line should be disregarded.
Any suggestions of how to implement such functionality?
Thanks!
Eyal.
|
|
|
|
|
Hi,
I try to develop a csharp smart device application.I want to try the RDA method to connect to the database .mdf located in my collegue'sPC
My code is like that:
using System;
using System.Linq;
using System.Data.SqlServerCe;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace ModeDifféré
{
public partial class Form6 : Form
{
public Form6()
{
InitializeComponent();
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void Form6_Load(object sender, EventArgs e)
{
string sConnection = "Data Source=Bacem-PC;User ID=sa;Password=sa;Initial Catalog=GMAO;Persist Security Info=false;";
string sSQL = "SELECT Nbt FROM 4BT; ";
SqlConnection conn = new SqlConnection(sConnection);
SqlCommand comm = new SqlCommand(sSQL, conn);
SqlDataReader dr = null;
try
{
comm.Connection.Open();
dr = comm.ExecuteReader();
while (dr.Read())
comboBox1.Items.Add(dr[0]);
}
catch (SqlException ex)
{
MessageBox.Show("connexion impossible");
MessageBox.Show(ex.Message);
return;
}
dr.Close();
comm.Connection.Close();
}
}
}
where bacem-PC is my freind'sPC server .He enables remote connexion to his sql server.
When running,this error appears:"specified sql server not found or acces denied"
As a note,this is the same arror that appears when I try locally in my PC
I am really fed up of this annoying error??
URGENT HELP I NEED or i will be a mad person
Thanks
|
|
|
|
|
Funny thing...
Afther a whole thread in which I tried to solve your problem but did not succed you are not demoralised and still prospecting for new solutions...
I like your persistence
You previously said that Visual Studio and Management Studio can connect to your database. If so: add a dataset to your project, and from Visual Studio's datasources (usualy in the left of the screen) drag your tables onto the dataset. This will generate code that connects to your database retrives rows and can update them. (If you don't know how to use this google for Dataset and Strongly Typed Dataset ).
I have no smart signature yet...
|
|
|
|