JerryShaw 46 Posting Pro in Training

Okay,
I assume you must be using VS2008, since it is less forgiving than VS2005.

You need to change it a little, and add some error checking.

public partial class Form1 : Form
    {
        private Form2 form2;
        
        public Form1()
        {
            InitializeComponent();
        }

        private void listBox1_Click(object sender, EventArgs e)
        {
            int i = form2.listBox1.SelectedIndex;
            if (i > -1)
            {
                string item = form2.listBox1.Items[i].ToString();
                int y = checkedListBox1.Items.IndexOf(item);
                checkedListBox1.SetItemCheckState(y, CheckState.Checked);
            }
        }

        private void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            if (e.NewValue == CheckState.Checked)
            {
                string item = checkedListBox1.Items[e.Index].ToString();

                if (form2.listBox1.Items.IndexOf(item) == -1)
                    form2.listBox1.Items.Add(item);
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            if (form2 == null)
            {
                form2 = new Form2();
                form2.listBox1.Click += new EventHandler(listBox1_Click);
                form2.Show();
            }
        }
    }

As I stated earlier, there was no error checking provided in the example.
Anyway, the listBox1_Click event handler now checks to make sure the index value is valid before processing it.

JerryShaw 46 Posting Pro in Training

Let me re-state your question to see if I understand you correctly.

You have two forms. First form has a check list box, and the second form has a listbox.
When the user checks an item in the check list box, you want that item to be added to the listbox on form 2. If the user unchecks the checkbox item, then do nothing.

If the user clicks an item in the listbox, you want to make sure the checklist box item on form 1 is checked.

To do this, form 2 must be visible to form1, and the listbox must have its modifier property set to public.

Create an event handler on the checklistbox, so that when a user changes the state of a check box to checked, it will see if this item exists in the listbox. If not, then add it.

When creating form2 , add an event handler in form1 for the listbox Click event, and have it verify the corresponding checkbox is checked.

public partial class Form1 : Form
    {
        private Form2 form2;
        
        public Form1()
        {
            InitializeComponent();
            form2 = new Form2();
            form2.listBox1.Click += new EventHandler(listBox1_Click);
            form2.Show();
        }

        void listBox1_Click(object sender, EventArgs e)
        {
            int i = form2.listBox1.SelectedIndex;
            string item = form2.listBox1.Items[i].ToString();
            int y = checkedListBox1.Items.IndexOf(item);
            checkedListBox1.SetItemCheckState(y, CheckState.Checked);
        }

        private void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            if (e.NewValue == CheckState.Checked)
            {
                string item = checkedListBox1.Items[e.Index].ToString();

                if (form2.listBox1.Items.IndexOf(item) == -1)
                    form2.listBox1.Items.Add(item);
            }
        }
    }

Error checking not included...

JerryShaw 46 Posting Pro in Training

Make sure you are placing the file into an appropriate column type such as image.
see attachment. I did this for someone on this forum some months ago with the same question.

// Jerry

JerryShaw 46 Posting Pro in Training

This thread is closed (or should be)
Started in Oct 2007, and the thread starter has not closed this thread.

JerryShaw 46 Posting Pro in Training

Sorry, typo.... you should not have to use LEFT JOIN on the employee table. You should however add foreign key constraints to force data integrity between all three tables.

To add an employee to a project, just add the Project_ID and Employee_ID combination to the Project_Employee table.

In normal form, you realize that Project is singlular, and Employee is singular. To stick with the rules, and allow an employee to belong to more than one project, you need the intermediate table that provides the relationship.
IOW, if you added Employee_ID to the project table, then a project can only have one employee.
If you add Project_ID to the Employee table, then an employee can only belong to one project.
If you use a delimited list, or XML field for employees in your project table as in your original structure... you are breaking the rules of normal form, plus the users of your table must have specialized knowledge of how employees are stored in this field... a big no-no.

Use of intermediate tables is standard practice in database modeling. Now you can expand each of the tables without harm to the relationship. Example: the intermediate table can include additional fields such as DateEmployeeAddedToProject, AddedByLoginAccountName, etc. (Items specific to this relationship, IOW, don't add employee age to the intermediate table.. it belongs to the employee table. Don't duplicate any field from either singlular table IOW dont add project_name to the intermediate table because it is already …

JerryShaw 46 Posting Pro in Training

I think you should re-write the tables as such:

CREATE TABLE [dbo].[Project](
	[Project_ID] [int] IDENTITY(1,1) NOT NULL,
	[Project_Name] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
 CONSTRAINT [PK_Project] PRIMARY KEY CLUSTERED 
(
	[Project_ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

CREATE TABLE [dbo].[Employee](
	[Employee_ID] [int] IDENTITY(1,1) NOT NULL,
	[Employee_Name] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
 CONSTRAINT [PK_Employee] PRIMARY KEY CLUSTERED 
(
	[Employee_ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

CREATE TABLE [dbo].[Project_Employee](
	[Project_ID] [int] NOT NULL,
	[Employee_ID] [int] NOT NULL,
 CONSTRAINT [PK_Project_Employee] PRIMARY KEY CLUSTERED 
(
	[Project_ID] ASC,
	[Employee_ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

You get Project, Employee, and Project_Employee

Projects and Employees are related through the Project-Employee table.
This is a standard Normal Form design.
Now you can have unlimited Projects with unlimited employess per project.

Join the tables and set your criteria as needed.

Select Project_Name,Employee_Name 
from Project p 
LEFT JOIN Project_Employee pe on p.Project_ID = pe.Project_ID
LEFT JOIN Employee e on pe.Employee_ID = e.Employe_ID
ORDER BY p.Project_Name
JerryShaw 46 Posting Pro in Training

rams111 - If you want to get more advanced functionality, then study up on SMO.
That is what SQL Studio uses in the background to do all the backup and restore work (and well everything else in Studio). I've been using it for a very long time (since SQLDMO).

It is probably more advanced than what you are ready for, but I figured I should mention it in case you are delving into full backup and restore management from C#.

// Jerry

JerryShaw 46 Posting Pro in Training

Simple way is to just mark the components in the second form as public (modifier property), and read the results back from the main form.

JerryShaw 46 Posting Pro in Training

Have you tried using a tab delimited file and give it the xls extenstion ?
Excel will open the file and treate it like an xls file.

// Jerry

JerryShaw 46 Posting Pro in Training

See attached from CodeProject

JerryShaw 46 Posting Pro in Training

Refresh ?
Do you mean to Restore ?

JerryShaw 46 Posting Pro in Training

What kind of DB ?
Access, Oracle, SQL, MySql, ???
The easy way is to just issue the SQL comands from an SqlCommand component.

JerryShaw 46 Posting Pro in Training

There are a number of approaches, but the easiest way would be to just pass the Main.cs label1 object to the second form, and let the buttons set its text.

Add the label as a parameter to the contructor.

India india = new India(label1);
.....

In the India.cs file setup the constructor and a variable

private Label mainLabel = null;

public India( Label mainLabel )
{
   this. mainLabel = mainLabel;
...
}

private void onSomeButtonClick(object sender, EventArgs e)
{
     Button myBtn = (Button)sender;
     mainLabel.Text = myBtn.Text;
....
}

Just typed this off the top of my head, so you may have to play with it, but I think you get the idea.

// Jerry

JerryShaw 46 Posting Pro in Training

You can set the contextmenu args e.Cancel = true to prevent the menu from appearing. If you cause a "significant" mouse movement, you need to set a variable so that in the contextmenu Opening event, it can be checked, and prevented from displaying if the variable is true. Always set this variable to false when entering the picturebox, or on the initial right mouse click event.

Hope this helps,
Jerry

JerryShaw 46 Posting Pro in Training

Here is what I did in the violationsForm1 class that is a bit different than yours.

namespace harcaype
{
    public partial class violationsForm1 : Form
    {
        mainForm parentForm = null;
        public violationsForm1(mainForm parentForm)
        {
            InitializeComponent();
            this.parentForm = parentForm;
        }

        public ListViewItem _listViewFrequent
        {
            get { return (ListViewItem)listViewFrequent.FocusedItem.Clone(); }
        }


        private void selectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            parentForm._listViewFreq = _listViewFrequent;
            Close();
        }
    }
}

and here is the mainForm

namespace harcaype
{
    public partial class mainForm : Form
    {
        public mainForm()
        {
            InitializeComponent();
        }

        public ListViewItem _listViewFreq
        {
            set
            { listViewNewData.Items.Add(value); }
        }

        private void fileVioToolStripMenuItem_Click(object sender, EventArgs e)
        {
            violationsForm1 vform1 = new violationsForm1(this);
            vform1.ShowDialog();
            vform1.Dispose();
        }

    }
}

I don't see where you are populating the violations listview, so I just through in some dummy data.
It moves data back to the main without any issues...
The only thing I did was change your constructor and parentForm property to be specifc to the mainForm class. If you really intend on using the violations form for multiple form classes, then I suggest you create an interface class, and use that in the constructor and form classes to allow dot-net to address properties without concern for the actual form class it is using.

// Jerry

JerryShaw 46 Posting Pro in Training

okay, Give me a few minutes to run your code into VS and try to duplicate your problem.

JerryShaw 46 Posting Pro in Training
private void mnuSelect_Click(object sender, EventArgs e)
        {
            //MessageBox.Show(listViewFrequent.FocusedItem.Text);
            
            mainForm frm = new mainForm();
            frm._listViewFreq = _listViewFrequent;
            frm.Show();
            this.Close();         
        }

Why are you doing this ? mainForm frm = new mainForm();
Should'nt it be (mainForm)parentForm._listViewFreq = _listViewFrequent;

// Jerry

JerryShaw 46 Posting Pro in Training

use type image instead of varbinary(max)

JerryShaw 46 Posting Pro in Training

Maybe you should send more code so I can see what you are trying to do. Everytime that you recreate that form, it calls initializecomponents which gives you a new blank listview.

JerryShaw 46 Posting Pro in Training
**************************************************************************************************
private void ShowForm(DataTable dtDagChauff)
{
if (FrmZTour == null )
{
FrmZTour = new FrmDgvZoomTour();
FrmZTour.SelectTour += new FrmDgvZoomTour.SelectTourHandler(DgvTourSelected);
FrmZTour.FormClosed += new FormClosedEventHandler(FrmZTour_FormClosed);
FrmZTour.Show(this);
}

FrmZTour.FillDgv(dtDagChauff);
}

private void FrmZTour_FormClosed(object sender, FormClosedEventArgs e)
{
     FrmZTour.Dispose();
     FrmZTour = null;
}
JerryShaw 46 Posting Pro in Training

Make sure the dot-net framework that is installed is version 2. CSC.exe is the c# compiler that VS and all tools use to create the actual c# executable. Each dot-net version has its own CSC.

JerryShaw 46 Posting Pro in Training

The ListviewItem is an object in a collection that belongs to a different listview.
To copy it to the other list, you have to clone it, or remove it (decouple) from its current collection and post it into its new parent.

public ListViewItem _listViewFrequent        
{            
    get { return (ListViewItem)listViewFrequent.FocusedItem.Clone(); }        
}

private void mnuSelect_Click(object sender, EventArgs e)
        {  
            mainForm frm = new mainForm();
            frm._listViewFreq = _listViewFrequent;
            frm.Show();
            this.Close();         
        }

??? Also, listview does not allow adding of STRINGS. Please help. ???
Explain ... maybe I can show you how to do what you want with strings.

// Jerry

JerryShaw 46 Posting Pro in Training

You can always purchase the InfoPower controls for dot-net. They have a sub-classed TreeView that connects directly to a dataset with multiple relationships to display the tree.

Or roll your own. Bottom line is that the treeview is not a true data-aware component out of the box. Check out this link: http://www.codeproject.com/KB/tree/dbTree.aspx for work originating with Duncan Mackenzie. It is a sub-classed TreeView component that might meet you needs.

In any case, you are going to have to write code (most likely a new class or component) to populate the tree. Keep in mind that typically 99% of the time, you are going to want to get to that table record to do additional work. IOW it is not just enough to display data... you need to be able to get to the underlying record.

// Jerry

JerryShaw 46 Posting Pro in Training

Get the data from the database with a new statement:
select byEmail from ContactDetails where byEmail = 'Y'

Then in c#:
foreach(DataRow row in YourDataSet.Tables["YourTable"].Rows)
sendYourEmailTo( row["byEmail"].ToString() );

Or if you already have the dataset loaded...
DataRow[] emailers = YourDataSet.Tables["YourTable"].Select("byEmail = 'Y'");
foreach(DataRow row in emailers)
sendYourEmailTo( row["byEmail"].ToString() );

Or if using an SqlDataReader...
SqlConnection conn = new SqlConnection( YourConnectionString );
SqlCommand cmd = new SqlCommand("select byEmail from ContactDetails where byEmail = 'Y'",conn);
conn.Open();
SqlDataReader row = cmd.ExecuteReader();
while (row.Read())
{
sendYourEmailTo( row["byEmail"].ToString() );
}
conn.Close();

// Jerry
PS: Just typed off the top of my head, so verify syntax before use.

JerryShaw 46 Posting Pro in Training

You mus tbe new to message boards. When you type in CAPS it means you are shouting.

The best advise is to visit amazon.com and pick up some books, and then as you run across problems, post them here and someone will help

JerryShaw 46 Posting Pro in Training

Well, you can see what happens when you turn the int into a hex.

int x = 123;
string hex = "0x" + x.ToString("X");
JerryShaw 46 Posting Pro in Training

Why not just use its handle?

string pname="notepad";

foreach (Process theprocess in Myprocess)
{
if (theprocess.ProcessName == pname)
{
postmessage( theprocess.Handle, WM_SYSCOMMAND, SC_MINIMIZE, 0);
break;
}
}
JerryShaw 46 Posting Pro in Training

The only way I know of to do this at design time is to create a new component that is a subclass of ToolStrip, and then add the extra functionality. Use your new component instead of the ToolStrip.

// Jerry

JerryShaw 46 Posting Pro in Training

Knowledgelover,

Let’s re-visit your original request.
You want to have a means of storing and retrieving secured setup information for your application.

To be persistent, it means either writing something to the registry or to a file (I will make the distinction even though the registry is also a file).

Don't get hung-up on file extensions. There is no standard for "info" files that I am aware of. IOW there is no commonly used association with any particular viewer for a file with this extension.

The easiest approach is to use the Properties | Settings item in the solution explorer.
Expand the Properties tree item in the solution explorer.
Select (double-click) the Settings.settings tree node.
A grid will appear.
I will assume that you want to strore two pieces of information. I will assume the first is named “UserName”, and the second will be “Password”.
In the first available row in the settings grid, enter the name of the variable “UserName”.
Enter a new row and set the name to “Password”.

The settings file will be saved as the name of your executable with the extension of “.config”. Example MyApplication.exe will have a file named MyApplication.exe.config
This config file is your info file. It will contain XML.

In your c# code you can read and write this information.

private void button1_Click(object sender, EventArgs e)
{
   string un = Properties.Settings.Default.UserName;
   string up = Properties.Settings.Default.Password;
   MessageBox.Show(string.Format("UserName={0}\r\nPassword={1}",un,up));
} …
JerryShaw 46 Posting Pro in Training

Knowlgelover,

A file is a file. Please explain "an info file is not an ordinary file that is represented by an IO" ?
Any non-corrupted file (and even corrupted files with the right viewer) can be opened an viewed by a user/hacker.

// Jerry

JerryShaw 46 Posting Pro in Training

Since no one has told you the standard ways yet..

Look at Property Settings

The next options are using home grown XML files, INI files or the Registry.

// Jerry

JerryShaw 46 Posting Pro in Training

The use of the Dataset allows you to save itself as an XML file to disk.
This means that the next time you load your application, the dataset can repopulate itself by loading the XML file.

This technique allows you to store and retrieve any kind of configuration information you could ever need. You can load multiple tables in the dataset, and all of them are saved with one line of code to save the entire dataset as an XML file.

// Saving a dataset to Disk
string FileName = "MyFileName.xml";
// VrfDataSet is my Configuration Dataset
VrfDataSet.WriteXml(FileName, XmlWriteMode.WriteSchema);
// Loading a dataset
string FileName = "MyFileName.xml";
if( File.Exists(FileName) )
{
     VrfDataSet.Clear();
            try
            {
                VrfDataSet.ReadXml(Filename);

.
.
.

Now you can use full flown database functionality to manage, find, etc any of your configuration information...

This Dataset is not connected to a real database... it is just a managed XML container that you can store connection strings, Bitmaps, a user supplied Icon for your app.. Just about anything you want to store in a configuration media.

// Jerry

JerryShaw 46 Posting Pro in Training

There are many ways to do this task, and I will let the others on this board give you the standard way(s) of doing this.

One method I have been using lately is quite simple, and does not require you to learn XML syntax or file IO management, or any of that stuff.

I drop a Dataset component on the main application.
I setup at least one table with the kind of information I want to persist. Briefcase Model.

When the application starts up, it will look for a file, and if found, the dataset will load it. Now all of my configuration information is found in the dataset. If I need to make changes to the configuration, I just make the changes to the dataset contents. When the application closes, I save the dataset to my filename.
One additional advantage is that I do not have to create a bunch of variables to maintain configuration information... It is already in my dataset along with Names, Types, etc.

The advantage of this method is that I can store multiple configurations, multiple types of configuration information, Bitmaps, documents, anything you want to stick into a DataTable.
Another advantage is that I can filter the configuration information for the currently logged on user (let each user customize the application to meet their needs).

Why read and write XML when you can just let the Dataset component do it for you.
Dataset XML files …

JerryShaw 46 Posting Pro in Training

If you are still having a problem, the post the first few lines of your Vidoe.cs file to this message board. The line that includes the word "class".

JerryShaw 46 Posting Pro in Training

When you double click the toolstripitem the IDE will create the evet handler. You want to know what to put in this new section of code.

{
Video video = new Video();
video.ShowDialog();
video.Dispose();
}

Typically your Video.cs file would contain the default Video Class. If you changed the name of the class in this file, then you would need to use the new name. If you changed the name of the file, then open the file and see what the name of the class is.
example, if it is like this, then use Video..., actually whatever the name is after the word "class" is what you want to use.

public partial class Video : Form

// Jerry

JerryShaw 46 Posting Pro in Training

He doesn't know about the magical pill that turns a mere mortal into a super developer.

They used to charge you for them magic pills at college, but I here you can get them from Amazon.com these days.

Just having fun with you.... post a set of questions, and we will see if we can help.

JerryShaw 46 Posting Pro in Training

Narue,

Help me understand your statement:

Ugh, no. Even encrypted, don't copy the password anywhere, period. Ideally you wouldn't even store it for authentication, instead favoring an irreversible hash[1]. The only place a string that can be restored to the original password should be allowed is the input box, and even then it should be discarded as quickly as possible.

Persistent storage of information is written to disk (aka file IO). No matter if you use MD5, hash algo, or any number of encrypting techniques. Even storing a value to the registry... guess where it ends up... on the disk. Guess where your local SAM account password is stored... on the disk, even if you are authenticated on AD, a copy gets placed into the local SAM in case you loose connection to the AD, you can log in locally. Persistent data means to store information in a media that will retain information without the use of external power.

I agree, storing passwords is an option that should be avoided, however it is done.
In many cases, the credentials are passed on to Database connections or many other sources requiring non AD credentials. In these cases your irreversable hash algo would not work.

So, if the application uses this "hateful" option.
I would expect that when the logon screen appears, it would first grab the account of the (Windows) currently logged on user, then go to my persistent source where I can search for …

JerryShaw 46 Posting Pro in Training

You are not giving much detail.
I assume you mean to save / store the password for this user if a checkbox is marked. Then when this user tries to log in the next time, you read back the password from whereever you stored it and use that instead of asking the user for the password.

So, store the username and password in a file (encrypted I hope), and on startup, if the file exists, load up the information.

// Jerry

JerryShaw 46 Posting Pro in Training

Funny... You are launching a new form1 inside your onLoad handler. Each one has this dialog, and each one launches another form1... a logical never ending loop. (until you run out of resources :)


// Jerry

JerryShaw 46 Posting Pro in Training

There is a variety of ways to do this. I will show you the one I use most often.

It all boils down to variable scoping. Form2 (child) needs to be able to see Form1(parent).
There are two properties in a Form (Parent and ParentForm), however you can not rely upon them being set because of the number of ways to create a form.
Therefore, what I typically do is pass the main form instance to the child form constructor.

private void button1_Click(object sender, EventArgs e)
        {
            button1.Enabled = false;
            Form2 myForm = new Form2(this);
            myForm.Show();
        }

Now, you need to have Form2 store the instance.

public partial class Form2 : Form
    {
        Form1 myParent = null;

        public Form2(Form1 myParent)
        {
            InitializeComponent();
            this.myParent = myParent;
        }

Once the child has this instance you can call any public method or property in the parent form. So in this example, I selected to set the modifier property of a button on the main form to public. Now Form2 can set the text of form1's button like this:

private void button1_Click(object sender, EventArgs e)
        {
            
            myParent.button2.Text = "Foo";
        }

Hope this helps,

Jerry

JerryShaw 46 Posting Pro in Training

Your question can be interpreted in many different ways.
Is the underlying data stored in an SQL Database ?
Is this a WEB app, or a Windows Application ?

Using the asumption that you are using SQL, there are a variety of ways of limiting rows a user can see.
One option I have used before is to create a GUI that allows an administrator to determine which users or user groups can access some key data. In your case, the "WOODGROVE" key. The Key data, along with the User or User Role would be included in a seperate table.

Then you can either write a stored procedure or create a view that will inner join the attendance list with this key table based on their suser_name() or joined by the database role. The result would be a listing customized for a specific user or member of a database role. IOW, they will only see attenance lists they are been given permission to see.

Hope this helps
// Jerry

JerryShaw 46 Posting Pro in Training

First things first,

You need to verify that you actually have byte data in the correct columns in the table.
I have the feeling that you do not really have the file data in the table. Looks like you only have the name of the encrypted file, but not the actual file byte array. Verify you have File Data in the table.

To "not" launch the file... remove all lines containing "Launcher" , example: Launcher = new Process // should be removed since you are not going to be running this file.

On the otherhand, if you are using an external decrypter for the file, then you need to pass the complete path of the file as a startinfo parameter, so you would retain Launcher, and setup the parameters correctly.

// Jerry

JerryShaw 46 Posting Pro in Training

Whoops, you have even more problems, here is a corrected version.

string line;
double score = 0;
count = 0;
while ((line = sr.ReadLine()) != null)
{
    score += double.Parse (line);
    count++;
}
averageScore = (double)inValue / count;
JerryShaw 46 Posting Pro in Training

Move the variable up. You can not redeclare the variable in the while statement.

JerryShaw 46 Posting Pro in Training

I modified your method as below.
In my File manager example, I added a button to call this method, after adding you Sql proc to use my FileRepository table.

Even with your previous code, I my reader was not null.
I suggest that you send an integer instead of text to the proc. Make sure it is a studentid that exists. The only reason the reader will be null is if there are no records returned.

public void getEncryptedAssignments()
        {
            myConnection = new SqlConnection(string.Format("Data Source={0};Initial Catalog={1};Integrated Security=True"
                    , ServerName
                    , DatabaseName)
                    );
            command = new SqlCommand("getEncryptedAssignments", myConnection);
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.AddWithValue("@studentID", 3);
            myConnection.Open();

            //Declare stored procedure parameters associated with database Assignment Table
            //command.Parameters.Add(new SqlParameter("@studentID", SqlDbType.Int, 4, "StudentID"));
            //command.Parameters["@studentID"].Value = 1; // txt_StudentID_RetrieveAss.Text;

            reader = command.ExecuteReader();
            //byte[] blobFile;
            //byte[] blobKey;
            //string fName;

            string OutFile = @"C:\"; //_DecryptedFile";
            //string OutKey = @"d:\_PublicKey";
            while (reader.Read())
            {
//                Label1.Text = "GRRRRR";
                //int byteCount = (int)reader.GetBytes(0, 0, null, 0, 0);
                //byte[] blobData = new byte[byteCount];
                //reader.GetBytes(0, 0, blobData, 0, byteCount);
                //fName = reader["Filename"] as string;
                //blobFile = reader["Assignment"] as byte[];
                LaunchedFile = (string)reader["Filename"];
                FileInfo fi = new FileInfo(LaunchedFile);
                FileStream fs = fi.Create();
                byte[] DataFile = new byte[0];
                DataFile = (byte[])reader["Assignment"];
                int ArraySize = new int();
                ArraySize = DataFile.GetUpperBound(0);
                fs.Write(DataFile, 0, ArraySize);
                fs.Flush();
                fs.Close();
                Launcher = new Process();                                        // Fire up a process
                Launcher.StartInfo.FileName = fi.FullName;                       // Give it the name of our file we just created
                Launcher.StartInfo.WorkingDirectory = OutFile;                   // Tell it to work in the temp directory
                Launcher.Start();
            }
            reader.Close(); …
JerryShaw 46 Posting Pro in Training

Show me your code including the SqlCommand

JerryShaw 46 Posting Pro in Training

choudhuryshouvi,

The code you sent earlier produced a different error on my machine.

This modified code below does run on my system. I changed the first assignment to drop the trailing backslash, and instead of using the OpenSubKey, I use the CreateSubKey. An old trick I learned way back is that the CreateSubKey WIN API call does the same thing as the OpenSubKey, except that it will also automatically create the subkey if it does not already exist.


// Jerry

private void cmdRead_Click()
        {
           RegistryKey HKCU=Registry.CurrentUser;
           RegistryKey subKeys=HKCU.CreateSubKey("Software\\VB and VBA Program Settings\\Company\\Login Status");
           subKeys.SetValue("Status", "Logged In");
           subKeys.Close();
           HKCU.Close();
        }
JerryShaw 46 Posting Pro in Training

See the attachment, there was a similar recent request for this, so I build a demo project.
You should be able to figure it out from this.

// Jerry

JerryShaw 46 Posting Pro in Training

Is the database getting installed ? IOW can you access it using SQL 2005 Studio on the client machine ?

If this is a question about connection strings (IOW the database is verified to be installed on the client and functional), then "Jen"'s answer should be all you need.

If your question involves the installation of the database on the client computer then read on:

If this is an SQL database, I suggest that you use an install package that knows what it is doing with SQL.

Typically using a T-SQL script has a better success rate, however if you know what you are doing, you can use the Attach datebase functionality of T-SQL (through ADO...other). The issues there are that you must make sure you have no special schemas created (created against a non existing user) , Simple file structure (aka not using FileGroups / database partitioning) and no database users assigned where the SID will not match.

// Jerry

JerryShaw 46 Posting Pro in Training

See if you can do it manually using RegEdit.
I think you will discover the problem as you navigate to the node where you are expecting to write the value.