|
I have a c# windows application with sql server databse.i need to deploy this project on my client's machine where sql server is not installed. so please clarrify my doubts
1.how to attach my database to set up file so that it is available to the client's machine.
2. as there is no sql server on the client machine, can i add sql server installer to the
set up file?if so how ...
if not ... any other way
3. and there are some problems with the sql server instances... help me out plz
|
|
|
|
|
Hi , have a good day
1- Don't Attach your database , Use Creation Script , INSERT Script , instead !
2- you can't add Sql files to the VS setup , the best way is to use http://www.installaware.com/[^]
Or you can Add the MSDE folder ( Sql Client ) next to your setup project
So the client can install it manually .
- I run the sql script to create database from my Application NOT from the setup
class InitSchema
{
private static string strScript = global::BuyerQty.Properties.Resources.Scheme;
public static void InitSchemaScript()
{
DBConnect.DBCommand = new OleDbCommand("USE " + clsSetting.DataBase, DBConnect.DBConnection);
DBConnect.DBCommand.ExecuteNonQuery();
strScript = strScript.Replace("GO", "~");
foreach (string strQuery in strScript.Split('~'))
{
try
{
DBConnect.DBCommand = new OleDbCommand(strQuery, DBConnect.DBConnection);
DBConnect.DBCommand.ExecuteNonQuery();
}
catch
{
}
}
}
}
I am C# Windows Applications , Sql programmer , and I have been through this case many times
- Only for my very stupid customers I use Click once installation for Sql like Installaware
- I use NSIS setup to deploy the Application and DotNet , and the Customer must install Sql Manually
P.S:
I hate to have 2 or more Sql Instance on my customer machine
Hope this help
I know nothing , I know nothing ...
modified on Sunday, July 18, 2010 5:38 PM
|
|
|
|
|
does c# support inherit attributes to for the child class ?
|
|
|
|
|
The ugly answer is some do, some don't.
For example, Serializable doesn't - because the class author has no idea if derived classes are serializable, it is up to the derived class author.
However it is possible to create class attributes with "Inherited=true" See Attributes in C#[^]
for details.
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
|
thanx..OriginalGriff. it really nice..i was also having the problem with serializable attribute, because the object class holds that attribute . it must be marked as false for inheritance .
thanx Abhinav S .
|
|
|
|
|
Hi
i have a simple app which display emplyees organization chart from northwind database. here is my code to accomplish this :
private void btnLoadData_Click(object sender, EventArgs e)
{
this.treeView1.Nodes.Clear();
this._dtEmployees = this.GetEmployees();
this.FillHieraricalData(this._dtEmployees, this.treeView1, "LastName", "EmployeeID", "ReportsTo");
this.treeView1.ExpandAll();
}
private DataTable GetEmployees()
{
DataTable dt = new DataTable();
using (SqlConnection con = new SqlConnection(Properties.Settings.Default.NorthwindConnectionString))
{
SqlCommand cmd = con.CreateCommand();
cmd.CommandText = "select * from employees";
con.Open();
dt.Load(cmd.ExecuteReader());
con.Close();
}
return dt;
}
private void FillHieraricalData(DataTable dt, TreeView treeView, string infoColumnName,
string pkColumnName, string parentColumnName)
{
TreeNode node = null;
foreach (DataRow row in dt.Rows)
{
node = new TreeNode(row[infoColumnName].ToString());
node.Tag = row[pkColumnName];
if (row[parentColumnName] != DBNull.Value)
{
List<TreeNode> foundNodes = new List<TreeNode>();
SearchNodeInTreeView(treeView.Nodes, Convert.ToInt32(row[parentColumnName]), foundNodes);
if (foundNodes.Count > 0)
foundNodes[0].Nodes.Add(node);
}
else
treeView.Nodes.Add(node);
}
}
private void SearchNodeInTreeView(TreeNodeCollection nodesToSearch, int value, List<TreeNode> foundNodes)
{
for (int i = 0; i < nodesToSearch.Count; i++)
{
if (Convert.ToInt32(nodesToSearch[i].Tag) == value)
foundNodes.Add(nodesToSearch[i]);
SearchNodeInTreeView(nodesToSearch[i].Nodes, value, foundNodes);
}
}
However, when i update data in memory (via dataTable) and redisplay data in treeView, the row that has been modfied has been removed from treeView and not display. for example, when i change 'Reports To' of any employee, that employee does not display in treeView! here is my code to accomplish this :
private void btnSave_Click(object sender, EventArgs e)
{
this.UpdateDataRowFromUI(this._currentRow);
this._dtEmployees.AcceptChanges();
this.treeView1.Nodes.Clear();
this.FillHieraricalData(this._dtEmployees, this.treeView1, "LastName", "EmployeeID", "ReportsTo");
this.treeView1.ExpandAll();
}
private void UpdateDataRowFromUI(DataRow row)
{
row["LastName"] = txtLastName.Text;
row["FirstName"] = txtFirstName.Text;
row["ReportsTo"] = cmbReportsTo.SelectedValue;
}
Where is my problem and how to solve it ?
thanks in advance ?
|
|
|
|
|
You are putting the row id into the tag property
node.Tag = row[pkColumnName];
But I don't see where you find that row to update the record when editing. You may be updating row[0] all the time.
I have been known to stick the entire row object into the tag property.
node.Tag = row;
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks Mycroft
but still i have the same problem.
|
|
|
|
|
|
If you have a question, post it here.
If you want us to download anonymous files from unknown people, think again.
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
Hi
I'm creating an application using the avicap dll. Currently it is still a testing app. There are two pictureboxes on the form, which are passed to the dll. Each picturebox is used for a different webcam. This all works beautifully. However when I activated both the webcams at the same time I noticed an extreme delays between the pictures from different cams and the application demands as low delays as possible. So I did some testing. First I ran two instances of the app. This showed no delays. So I thought, perhaps the delays are from running in the same thread. But that can't be, because the dll uses callbacks. So I ran a single instance of the app, but covered one of the pictures with another app (notepad). Delay was gone for as long I covered one of the pictures entirely. So it has to be the paint event. Is there a way to tell the application to sync these events? Or catch them and to sync myself?
Steven
|
|
|
|
|
Hi,
1.
I'm not sure I follow the logic in your post. However:
2.
Turning an image (probably JPEG file or stream) into a visible image on screen takes some time. If you want to have several new images appear as close together as possible, I would:
- create bitmaps of the right size
- when all of them are available, assign those to the PictureBoxes' Image properties (with PictureNoxSizeMode.Normal)
so I would not let the PB do any decoding nor resizing.
3.
And in fact I would not even be using PictureBoxes at all, they are pretty useless anyway, except for the simplest of jobs, which you can easily deal with otherwise, e.g. using a Panel and a Paint event handler.
PS: don't forget to dispose of images/bitmaps you no longer need!
|
|
|
|
|
Hi
You're completely right about the picturebox, I will change it with a panel right away.
Saving the images and applying them when the are all ready is not an option. It's a live video feed.
The picturesboxes are passed on with their handle, so I don't really know how the dll does it, but I guess it simply draws the image in the region of the control. The performance here is sufficient at the moment, except when I run two cams at once AND in the same app window. On seperate instances the performance is again optimal. I came to the conclusion that the dll invokes the paint method, but since two cams are active they continuously call the paint method. Hereby using (theoretically) the double amount of time. This wouldn't occur when I can sync the paint events, so the form is only invalidated when both cams send data. Or an other idea... Since running two instances, each with an other cam, doesn't give any performance loss either. I could split the paint event into a left and right section of the form somehow...
I hope this explanation was a bit more helpful
Steven
Off-topic: Were you on the news today? I saw your name passing by, but maybe it was someone else. Just curious though
|
|
|
|
|
if two processes work fine for you, you can have three of them: two camera ones, and a master; each camera would display into its own Form, the master would host those Forms using TopLevel=false;
What news?
|
|
|
|
|
Wow... what??
Do you mean two forms inside a master form? Or am I misreading that?
Something about children getting sick at a camp due to food poisoning.
|
|
|
|
|
Steven Solberg wrote: two forms inside a master form?
sure
Steven Solberg wrote: food poisoning
wasn't me!
|
|
|
|
|
I did something wrong or it isn't working...
Still the same story, when I activate both the webcams the delay pops up. When I cover one of the controls up the delay is gone. This is what I added to my code.
this.FrontCam = new frmCam("FrontCam");
this.FrontCam.ClientSize = new System.Drawing.Size(194, 176);
this.FrontCam.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.FrontCam.Location = new System.Drawing.Point(12, 74);
this.FrontCam.Name = "FrontCam";
this.FrontCam.Text = "FrontCam";
this.FrontCam.TopLevel = false;
this.FrontCam.Visible = true;
this.SideCam = new frmCam("SideCam");
this.SideCam.ClientSize = new System.Drawing.Size(194, 176);
this.SideCam.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.SideCam.Location = new System.Drawing.Point(218, 74);
this.SideCam.Name = "SideCam";
this.SideCam.Text = "SideCam";
this.SideCam.TopLevel = false;
this.SideCam.Visible = true;
this.Controls.Add(this.FrontCam);
this.Controls.Add(this.SideCam);
Edit: I am such a retard... I can set the area in which the webcam image should be drawn. I just have to set this to use half a panel for each webcam. I'll try this and return to tell how it works out.
Edit 2: Nope... that didn't work either
modified on Saturday, July 17, 2010 3:45 PM
|
|
|
|
|
Hi again
I'm still stuck with this problem. I have tried to use two forms, one for each webcam device. Next to that I have tried to use a single panel and draw both captures in that panel. One capture next to the other. Still no improvement.
I keep coming to this conclusion: Both the captures call the paint event independently, which theoretically doubles the amount of calls to the forms paint method. When I cover one of the captures, the paint method is called half as much and the capture appears smooth. When I use two seperate forms, the calling of paint methods is also cut in half since every form handles only the drawing of its own capture device.
So if I were able to sync the calling of the paint method, it would limit the amount of calls and improve performance. But I need to have these captures in one form. Additionally, later on these captures will be used for eye-tracking and image processing in real-time.
Thanks in advance
Steven
|
|
|
|
|
Hello everyone,
I have been trying to cast some pointers in 'unsafe' code block but running into the following error:
error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type ('DataType')
My code is as follows:
protected unsafe int MyFunc<DataType, TagType>(ref int nValues, ref DataType* values)
{
....
DataType[] valuesArr = new DataType[nValues];
GCHandle valuePtr = GCHandle.Alloc(valuesArr, GCHandleType.Pinned);
values = (DataType *)valuePtr.AddrOfPinnedObject().ToPointer();
}
This code is called from unmanaged side and basically I would like to cast the pointer from GCAlloc to the correct type... I am guessing it is not allowed even within an unsafe code block.
Just wondering if there is any way around this?
Many thanks,
Keith
|
|
|
|
|
That does not make sense to me, for a couple of reasons.
1.
Your DataType is a managed type, so why would you want that as a parameter in an unmanaged callback? Pointers that cross the managed/unmanaged border should be understood on both sides, good examples would be int* for a simple array, or IntPtr for just almost everything. So you don't need AddrOfPinnedObject().ToPointer(), AddrOfPinnedObject() suffices.
2.
The GCHandle you create needs to stay alive, so it cannot be a local variable inside a callback method. Remember, you need to call Free() on it when done, otherwise the object remains pinned forever.
Note: if your callback were called more than once, a single class-level IntPtr would not be sufficient either.
FWIW: I have this unfinished article[^] on P/Invoke.
|
|
|
|
|
Luc Pattyn wrote: FWIW: I have this unfinished article[^] on P/Invoke.
I quickly skimmed through it. Already looks great. When finished it'll definitely be an article that people can link to when replying to P/Invoke questions.
|
|
|
|
|
Thanks Nish. Unfortunately it will never be finished, there's always things to be added, until it becomes an unreadable 3-tome encyclopedia. OTOH, I'm doing a lot of P/Invoke but tend to keep things simple (and high-performant), so I may never know all there is to know on the subject.
|
|
|
|
|
I second Nish's comments - I was actually about to send you an email asking 'where your P/Invoke article was' becuase I had lost the link haveing looked at it some time before
(Im contemplating interfacing from c# to a 3rd party DLL .. all the time, my brain was going "where is that article from Luc", that will save me)
so cheers & thanks Luc
|
|
|
|
|
You could always use the "My Articles" link in my sig...
|
|
|
|
|