|
Hello good fellas
I'm struggling since this morning about this sqlite thing.after reading some good tutorials i decided to use it as my embedded database in my winform application.
i downloaded SQLite-1.0.61.0-setup that install the system.datal.sqlite for me and downloaded the firefox plugin sqlite manager and another management tool called wxSQLitePlus found <a href="http://cfred.free.fr/wxsqliteplus.php">here</a> based on this tutorials found <a href="http://decoding.wordpress.com/2009/01/14/using-sqlite-with-net/">here</a> (just being explicit)
Hoping i'm not posting any stupid stuff that will be ignored, here are my 2 challenges.
the first challenge is that i can't reference the database inside a folder let'say database
i have exception "Unable to open the database file".my app.config is as follow
<code><connectionStrings>
<add name="embcon" connectionString="Data Source=database\iagency.db;Version=3;"/>
</connectionStrings></code>
but if the iagency.db is inside the root folder there is no problem at all.app.config like
<code><connectionStrings>
<add name="embcon" connectionString="Data Source=iagency.db;Version=3;"/>
</connectionStrings></code>
the second chalenge is that object created via tools such as either firefox plugin or wxsqlite+
cannot be queried inside visual studio 2005 that i'm using.if it's a table when queried , i have an excetion the object doesn't exist even though both tools displays the same data.
and inversly table created by queries inside visual studio cannot be viewed by the tools.
so what's the deal?
is it a memory stuff or i'm just missing some points?
can enybody explain what is happening ?Thanks for reading.
eager to learn
|
|
|
|
|
i just wanted to precise that i can connect to the database though the server explorer.and there is no table created from visual studio queries.but the table's data can be displayed on a grid when i run it.weird!!
hanging on your replies, i can't find anything meaningful to my case.thanks
eager to learn
|
|
|
|
|
I have to find a folder from the path where my application exist e.g. c:/programfile/RTGSL/exe/..
then from exe folder i have to copy two folders(with all data) name applicationdata & client from this path to the current logged in user's personal folder path i.e. C:\Documents and Settings\ashishjaiswal\Application Data\clientdata\ if and only if no folder exist at this path..
Can any body help me with this code .. I am really new to programming
|
|
|
|
|
OK, this one is not as easy as you would like to think. As far as I know you need to do all the work here.
Basically, you should first obtain you two folder paths. Application path can be obtained using...
string sourceDir = Application.StartupPath + "\\FolderToCopy";
Then you destination path should be available in the System.Environment.SpecialFolder enum, im not sure which one you will want to use thou so either test a few or google for answers...
string destDir = System.Environment.SpecialFolder.ApplicationData;
Now you need to create a recursive function that will copy a folder and all sub-folders and files. Keep in mind this is off top of my head so sorry if it does not work as it should...
void CopyFolder(string source, string destination)
{
System.IO.DirectoryInfo info = new System.IO.DirectoryInfo(source);
System.IO.Directory.CreateDirectory(destination);
foreach(System.IO.FileInfo file in info.GetFiles())
{
file.CopyTo(destination + "\\" + file.Name);
}
foreach(System.IO.DirectoryInfo dir in info.GetDirectories())
{
CopyFolder(dir.FullName, destination + "\\" + dir.Name);
}
}
..sorry if it does'nt work properly, but im sure you can google for 'C# Copy Directory' and get the code you need
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
musefan wrote: string destDir = System.Environment.SpecialFolder.ApplicationData;//I guess this one is right
Actually, it's
string destDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
|
|
|
|
Hi,
I wanted to know how can I make a new object in a specific event,that can be public and visible to any other events in the same class?
I'll be thankful if anybody could guid me.
|
|
|
|
|
Do you mean an instance of an object? Or define an object such as a class? I am not sure what you mean - what are you trying to use it for?
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
I'm trying to use a MDI form.the cihld is a class,right?so whenever user trys to make a new child form (by pressing the new btn in the menustrip in the parent form),it makes it for the first time,but as soon as you close the child form and try to make a new one the error happens.that error is because I made the child object out of the event code block.the error says you have disposed an object (which is due to the object I made OUT OF EVENT) you can't use it any more.see,I know what's wrong but don't have the cure!here is a sample code block(in the parent form) :
new ChildTest myTest = new ChildTest()
public Form1()
{
InitializeComponent();
}
private void toolTest_Click(object sender, EventArgs e)
{
myTest.MdiParent = this;
myTest.Show();
}
private void toolBackColor_Click(object sender, EventArgs e)
{
myTest.BackColor = Color.Red;
}
|
|
|
|
|
pcsience wrote: //ChildTest myTest = new ChildTest();
Why you comment this line out, if you just make it a new instance, rather than a new declaration it should work...
myTest = new ChildTest();
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
hey man,
it did'nt do any good!!any more suggestions?see...I only need to define myTest in the toolTest_Click event in a way that toolBackColor_Click event can see it too.as you can see I wrote a code line in in comment type in toolTest_Click event,but that myTest is only visible in that event,not in the toolBackColor_Click.that's the main problem!!!
|
|
|
|
|
Firstly, what is this line supposed to do?
new ChildTest myTest = new ChildTest()
pcsience wrote: I know what's wrong
I don't think you do.
If you want the BackColor button to work for any MDIChild, you should not be referencing a specific form, rather you should be referencing the ActiveMDIChild property (testing it for null, of course).
Can I suggest that you study Creating MDI application using C# (Walkthrough)[^] from here on CP before continuing.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
ok,that line was wrongly typed here
new ChildTest myTest = new ChildTest() the correct one is
public ChildTest myTest = new ChildTest()
that's the point,once it has disposed an object (in this case the child form) it can't create another child form so that I can use ActiveMDIChild property!and I think that is because I created the child form object out of toolTest_Click event.when for the first time I run it,I can create a new child form but as soon as I close the child form and press the toolTest_Click the error occurs.which is in the
myTest.Show(); part.and it says Cannot access a disposed object. but if I just can make the object in the toolTest_Click event the error won't happen again,BUT other methods can't recognize it!
|
|
|
|
|
Closing the childform disposes it. The point of an MDI interface is that it allows you to have many child windows open, which is why I suggested using ActiveMDIChild.
If you want to use your toolTest_Click you must either test that ActiveMDIChild is not null and return if it is, or you must add myTest = new ChildTest() to the method. The problem with the last option, is that you will end up with lots of myTest forms open, just to test your methods. Alternatively don't close the first instance of ChildTest().
This is why I suggested that you read the article I gave the link for. Also the MDI Walkthroughs on MSDN are not bad, such as this one[^].
If you study either, or both of these, you will get a better understanding, because it is obvious that you are misunderstanding something about Windows Forms Programming in general and MDI in particular.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
hey man,
just wanted to say thanks.it worked.you did help me find the way.
|
|
|
|
|
I'm building a very simple composite control and when use the designer to select a data source it crashes Visual Studio 2008.
Here is the code:
namespace WebControlDesigner {
[ToolboxData("<{0}:ControlWithTasks runat=\"server\"></{0}:ControlWithTasks>")]
public class ControlWithTasks : CompositeDataBoundControl {
public ControlWithTasks() : base() { }
[Category("Apearance")]
[DefaultValue("Your Birthday")]
public string Prompt {
get { return (string)ViewState["Prompt"] ?? "Your Birthday"; }
set { ViewState["Prompt"] = value; }
}
[Category("Data")]
[Bindable(true)]
public DateTime Birthday {
get { return (DateTime?)ViewState["Birthday"] ?? DateTime.Now; }
set { ViewState["Birthday"] = value; }
}
protected override int CreateChildControls(IEnumerable pDataSource, bool pBinding) {
base.CreateChildControls();
Label vLabel = new Label();
vLabel.Text = Prompt;
vLabel.ForeColor = Color.Red;
this.Controls.Add(vLabel);
Literal vLiteral = new Literal();
vLiteral.Text = ": ";
this.Controls.Add(vLiteral);
TextBox vTextBox = new TextBox();
vTextBox.ID = "TextBox1";
vTextBox.Text = Birthday.ToString();
this.Controls.Add(vTextBox);
return 0;
}
}
}
It's an extremely simple control, and builds without error.
Here is the page that consumes it:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="WebControlDesigner" Namespace="WebControlDesigner" TagPrefix="wcd" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<wcd:ControlWithTasks ID="ControlWithTasks1" runat="server">
</wcd:ControlWithTasks>
</div>
</form>
</body>
</html>
It renders perfectly and display the designer menu correctly but if I create a data source or try to select a existing one it crashes VS2008.
What is missing?
Please!! I need some help.
|
|
|
|
|
HI
I am confused about how i can use internet in C#.
every help would be appreciated.
thanx
kakarman
|
|
|
|
|
Well that depends what you what to use the internet for?
If you want to browse web pages and you are using C#.Net forms then there is a control called WebBrowser which has some properties and functions to allow web browsing, you could look into that
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
kakarman wrote: I am confused about how i can
kakarman wrote: every help would be appreciated.
Sure. See the way it works is, you find some materials designed to explain something and you study it. That typically means reading the material and thinking about it. This is what is sometimes called learning.
|
|
|
|
|
or fetching a page into a string like so[^].
|
|
|
|
|
Hi.....
I have combobox which gives table list.After selecting table from same then crystal report view must show table data.
I got problem with crystal report binding.I am using C#.net and in my code i m using "dataset1 Ds" which retrieve all values but cant show that data into crystalreport viewer.
kindly find my code below......
<pre>
private void cmb_type_SelectedIndexChanged(object sender, EventArgs e)
{
if (Convert.ToInt32(cmb_type.SelectedIndex) == -1 && (Convert.ToString(cmb_type.SelectedValue) == "System.Data.DataRowView"))
{
return;
}
CrystalReport1 objRpt;
objRpt = new CrystalReport1();
String ConnStr = "Data Source=SHREE\\SQLEXPRESS;Initial Catalog=NandKumar;Integrated Security=True";
SqlConnection myConnection = new SqlConnection(ConnStr);
string Query1 = "Select * from " + cmb_type.Text ;
SqlDataAdapter adapter = new SqlDataAdapter(Query1, ConnStr);
DataSet1 Ds = new DataSet1();
adapter.Fill(Ds,"C"); // " + cmb_type.Text + "
if (Ds.Tables[0].Rows.Count == 0)
{
MessageBox.Show("No data Found", "Project Tracker Suite");
return;
}
// Upto this my code run- ok,i got problem from here...
objRpt.SetDataSource(Ds.Tables["C"].DefaultView);
CrystalDecisions.CrystalReports.Engine.TextObject root;
root = (CrystalDecisions.CrystalReports.Engine.TextObject)objRpt.ReportDefinition.ReportObjects["txtHeader"];
root.Text = "Sample Report With Parameter!!";
crystalReportViewer1.Visible = true;
crystalReportViewer1.ReportSource = objRpt;
}
}
|
|
|
|
|
hi friends
I want to know how to C# user interfaces invoke external tool kit like HTK 3.3 windows binary
please
|
|
|
|
|
Hi guys!
I'm writing a C# application that should use my cellphone's microphone as my pc microphone.
right now I'm using in the hand 32feet API to create the software but I'm not sure about in the hand's support for this one.
I'm looking for some example\ Explanation\ forum\ anything to start programming right(in C# - VERY IMPORTANT!).
just to mension - I've never did such thing and it's my first time programming for BT.
looking forward for your answers!
AMDO.
|
|
|
|
|
Ami Vaknin wrote: I've never did such thing and it's my first time programming for BT.
I've a feeling it could be your last too.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
yeah you must be right.
OK, now you can take your medicine.
good boy!....
go f*** yourself ya ben elef sharmutot.
|
|
|
|
|
When I drop an item into a ListView I get an out of memory exception... but... I have them on the same form.. within the same TabControl (different tabs though).
Basically I am saving the file... if the item is to be sent to M&R then I set the MR column (BIT) to True, and if not, then False. This way I can tell which ListView the item should show up in... But I get an error on the drag and dropping to the second listview (the M&R one)
private void listViewFiles_DragDrop(object sender, DragEventArgs e)
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
foreach (string file in files)
{
newFile = new OpenFileDialog();
newFile.FileName = file;
SaveFileThread(file, newFile.SafeFileName, false);
newFile.Dispose();
}
bwLoadFiles.RunWorkerAsync();
}
private void lstMRFiles_DragDrop(object sender, DragEventArgs e)
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
foreach (string file in files)
{
newFile = new OpenFileDialog();
newFile.FileName = file;
SaveFileThread(file, newFile.SafeFileName, true);
newFile.Dispose();
}
bwLoadFiles.RunWorkerAsync();
}
Here is what it is calling:
private void SaveFileThread(string Filename, string SafeFile, bool MR)
{
RegistryAccess reg = new RegistryAccess();
SqlConnection conn = new SqlConnection(reg.ReturnConnection);
SqlCommand cmd = new SqlCommand("SELECT * FROM Inventory_Files WHERE FilesID=@FilesID AND [Filename]=@Filename AND MR=@MR", conn);
try
{
cmd.Parameters.AddWithValue("@FilesID", txtTAG.Text);
cmd.Parameters.AddWithValue("@Filename", SafeFile);
cmd.Parameters.AddWithValue("@MR", MR);
conn.Open();
SqlDataReader myReader = cmd.ExecuteReader();
if (myReader.HasRows)
{
if (MR) Invoke(new FilesLabelDelegate(FilesLabel), new object[] { "Did not save. File already exist.", true });
else Invoke(new FilesLabelDelegate(FilesLabel), new object[] { "Did not save. File already exist.", false });
}
else
{
conn.Close();
FileStream fs = new FileStream(Filename, FileMode.Open, FileAccess.Read);
decimal Size = fs.Length;
byte[] buffer = new byte[fs.Length];
fs.Read(buffer, 0, (int)fs.Length);
fs.Close();
if (MR) Invoke(new FilesLabelDelegate(FilesLabel), new object[] { "Saving file.. Size: " + Math.Round((Size / 1024) / 1024, 2) + "MB", true });
else Invoke(new FilesLabelDelegate(FilesLabel), new object[] { "Saving file.. Size: " + Math.Round((Size / 1024) / 1024, 2) + "MB", false });
conn = new SqlConnection(reg.ReturnConnection);
cmd = new SqlCommand("INSERT INTO Inventory_Files (FilesID, Saved_File, Filename, File_Size, MR) VALUES (@FilesID, @File, @FileName, @Size, @MR)", conn);
cmd.Parameters.AddWithValue("@FilesID", txtTAG.Text);
cmd.Parameters.AddWithValue("@File", buffer);
cmd.Parameters.AddWithValue("@FileName", SafeFile);
cmd.Parameters.AddWithValue("@Size", Size);
cmd.Parameters.AddWithValue("@MR", MR);
conn.Open();
int Success = cmd.ExecuteNonQuery();
if (Success > 0)
{
if (MR) Invoke(new FilesLabelDelegate(FilesLabel), new object[] { "Saved file.", true });
else Invoke(new FilesLabelDelegate(FilesLabel), new object[] { "Saved file.", false });
}
}
}
catch (Exception ex) { new Errors(ex).ShowDialog(); }
finally { conn.Close(); }
}
|
|
|
|