|
I am able to store my pictures into the sql server using the following code:
private void pictureBox3_DoubleClick(object sender, EventArgs e)
{
intASUserListSelectedIndex = lbxAssistSuiteUserList.SelectedIndex;
bool FoundUser = false;
FileDialog fldlg = new OpenFileDialog();
//specify your own initial directory
if (lbxAssistSuiteUserList.SelectedIndex > -1)
{
try
{
fldlg.InitialDirectory = @":C\";
//this will allow only those\ file extensions to be added
fldlg.Filter = "Image File (*.jpg;*.bmp;*.gif)|*.jpg;*.bmp;*.gif|(*.gif)|*.gif|(*.jpg)|*.jpg|(*.jpeg)|*.jpeg|(*.bmp)|*.bmp|(*.wmf)|*.wmf|(*.png)|*.png";
//fldlg.ShowDialog();
if (fldlg.ShowDialog() == DialogResult.OK)
{
imagename = fldlg.FileName;
Bitmap newimg = new Bitmap(imagename);
pictureBox3.SizeMode = PictureBoxSizeMode.Zoom;
pictureBox3.Image =(Image)newimg;
//pictureBox3.Image = System.Drawing.Image.FromFile(openFileDialog1.FileName);
pictureBox3.Refresh();
//Update the SQL Tables.
lbxAssistSuiteUserList.SelectedIndex = intASUserListSelectedIndex;
btnUpdateAssistUsers_Click(sender, e);
lbxAssistSuiteUserList.SelectedIndex = intASUserListSelectedIndex;
updatedata();
}
fldlg = null;
lbxAssistSuiteUserList.SelectedIndex = intASUserListSelectedIndex;
}
catch (System.ArgumentException ae)
{
imagename = " ";
MessageBox.Show(ae.Message.ToString());
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
}
private void updatedata()
{
bool FoundMe = false;
int UserIndex = -1;
//use filestream object to read the image.
//read to the full length of image to a byte array.
//add this byte as an oracle parameter and insert it into database.
try
{
//proceed only when the image has a valid path
if (imagename != "")
{
FileStream fs;
fs = new FileStream(@imagename, FileMode.Open, FileAccess.Read);
//a byte array to read the image
byte[] picbyte = new byte[fs.Length];
fs.Read(picbyte, 0, System.Convert.ToInt32(fs.Length));
fs.Close();
//open the database using odp.net and insert the data
string connstr = WhatIsMyConnectionString;
SqlConnection conn = new SqlConnection(connstr);
conn.Open();
//Find the index
for (i = 0; i < ApplicationUsersArray.Count; i++)
{
if (((DomainUsersClass)ApplicationUsersArray[i]).WindowsLogonName == lbxAssistSuiteUserList.Items[lbxAssistSuiteUserList.SelectedIndex].ToString())
{
FoundMe = true;
break;
}
}
if (FoundMe = true)
{
UserIndex = Convert.ToInt32(((DomainUsersClass)ApplicationUsersArray[i]).Index);
}
else
{
MessageBox.Show("We have a serious problem. This should Never Happen. \n The Array did not find the correct users to grab their index for the Picture. \n The Application will now quit.");
Application.Exit();
Application.ExitThread();
}
string query;
query = "insert into tblApplicationUsersPic(id_image,pic) values(" +
UserIndex.ToString() + "," + " @pic)";
SqlParameter picparameter = new SqlParameter();
picparameter.SqlDbType = SqlDbType.Image;
picparameter.ParameterName = "pic";
picparameter.Value = picbyte;
SqlCommand cmd = new SqlCommand(query, conn);
cmd.Parameters.Add(picparameter);
cmd.ExecuteNonQuery();
if (FoundMe = true)
{
SQLUpdate(WhatIsMyConnectionString, "tblApplicationUsers", "tblApplicationUsersPic_idx = (Select idx_tblApplicationUserPic from tblApplicationUsersPic where id_image = '" + UserIndex.ToString() + "') ","delflag = 0 and idx_tblApplicationUsers = '" + UserIndex.ToString() + "' ");
//UserIndex = Convert.ToInt32(((DomainUsersClass)ApplicationUsersArray[i]).Index);
}
MessageBox.Show("Image Added");
cmd.Dispose();
conn.Close();
conn.Dispose();
Connection();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void Connection()
{
//connect to the database and table
//selecting all the columns
//adding the name column alone to the combobox
try
{
string connstr = WhatIsMyConnectionString;
SqlConnection conn = new SqlConnection(connstr);
conn.Open();
empadap1 = new SqlDataAdapter();
empadap1.SelectCommand = new SqlCommand("SELECT * FROM tblApplicationUsersPic", conn);
dset = new DataSet("dset");
empadap1.Fill(dset);
DataTable dtable;
dtable = dset.Tables[0];
comboBox1.Items.Clear();
foreach (DataRow drow in dtable.Rows)
{
comboBox1.Items.Add(drow[0].ToString());
comboBox1.SelectedIndex = 0;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
But I am unable to retreive the picture from the Sql Server.
Here is my current code to retreive the picture, it keeps erroring saying I do not have something defined and when I define it it still does not work....
Here is the code I use to retreive the image from the database.
//Picture of the User
DataTable dataTable = dset.Tables[0];
if (pictureBox3.Image != null)
{
pictureBox3.Image.Dispose();
}
for (i = 0; i < ApplicationUsersArray.Count; i++)
{
if (((DomainUsersClass)ApplicationUsersArray[i]).WindowsLogonName == lbxAssistSuiteUserList.Items[lbxAssistSuiteUserList.SelectedIndex])
{
break;
}
}
if (((DomainUsersClass)ApplicationUsersArray[i]).PicIndex != "0" || ((DomainUsersClass)ApplicationUsersArray[i]).PicIndex != "")
{
try
{
//using filestream object write the column as bytes and store it as an image
FileStream FS1 = new FileStream("image.jpg", FileMode.Create);
foreach (DataRow dataRow in dataTable.Rows)
{
//if (dataRow[0].ToString() ==
byte[] blob = (byte[])dataRow[1];
FS1.Write(blob, 0, blob.Length);
FS1.Close();
FS1 = null;
pictureBox3.Image = Image.FromFile("image.jpg");
pictureBox3.SizeMode = PictureBoxSizeMode.Zoom;
pictureBox3.Refresh();
}
}
catch
{
MessageBox.Show("Picture retrival Error");
ErrorLogWriter("We have a issue with retreiving the picture stored in the sql server table.");
}
}
|
|
|
|
|
It might help is you gave the error message (in full) simply saying that "it says something is not defined" doesn't help us to pin down the problem.
What is it that you have not defined?
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.”
|
|
|
|
|
I need a formula to calculate the difference in Hours and Minutes between two times.
Example: Table name = attandance and the fields that need to be calculated are:
[timein] = 1:15 PM
[timeout] = 1:44 PM.
I need the formula create a calculated field which equals 0:29.
I know the fomula that makes this work in Access (=HoursAndMinutes([Shipped]-[Picked]) but I need to write a Crystal report.
Thanks In Advance
|
|
|
|
|
I think that you will be wanting this.
<a href="http://weblogs.sqlteam.com/jeffs/archive/2007/08/29/SQL-Dates-and-Times.aspx">http://weblogs.sqlteam.com/jeffs/archive/2007/08/29/SQL-Dates-and-Times.aspx</a>[<a href="http://weblogs.sqlteam.com/jeffs/archive/2007/08/29/SQL-Dates-and-Times.aspx" target="_blank" title="New Window">^</a>]
From my limited knowledge crystal uses sql language and I believe this will explain how to subtract the 2 time stamps as a date time stamp...
The other way to go about this is to substring the field seperating the hours and minutes into variables and manually do the subtraction into the result.
|
|
|
|
|
this link is not working.
|
|
|
|
|
Hi all,
I am working on Medical transcription voice file format conversion. I need a help on This voice file (.DSS, .DSS2) to WMA or WAV file format conversion. Anybody have an idea feel free to post or share with me.
Thanks in Advance.
pandu
|
|
|
|
|
Hello, I just want to know if its possible to include the delimiter in the string output??
For example:
char[] delim = new char[] {';', ' '};
and the output:
for(int
x=0;
x<5;
x++)
Is there a way without using regex class?
|
|
|
|
|
See String.Split method.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
I think you didn't understand what i mean..What i really want to say is if for example i have a semi-colon which is a delimiter, is it possible to still include the semicolon to the splitted string?
For example:
string str = "for(int x=0; x<5; x++) Console.WriteLine("Hello");
in the above example, i want to split the string using the delimiter semi-colon, but at the same time i want it to be included in the splitted string.
For example, instead of this output:
for(int
x=0
x<5
c++)
I want this kind of output:
for(int
x=0;
x<5;
x++)
If you'll notice the semicolon, which is a delimiter is also included in my desired output...Is this possible?
|
|
|
|
|
Good luck with for ( int x = 0 ; x < 5 ; x++ )
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Is there a way on how to ignore or delete the whitespace? I presume that using Trim() method wouldn't do the work.
|
|
|
|
|
The correct way to deal with all the problems you are going to encounter is to write a real lexer and parser.
You can choose not to, and implement some shortcuts; chances are someone will come up with a case you can't handle. Here is one example:
for (int i = 0; i < "this is not a for(; ; ) loop".Length; i++) {...}
proving you need to understand string literals to recognize a for statement.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Luc Pattyn wrote: chances are someone will come up with a case you can't handle.
You're right about that. We'll be presenting our program next week and defend it like our real thesis. this is only a project that will apply data structures. And when i read about parsing there many ways on how to parse a statement. The one that I think will do our program done is the bottom - up parsing which uses a stack and a parse tree. Now the problem is i don't know where to get the pattern that i'll use to accomplish that. I think the best way is to somehow find a way on how to do that and state to our presentation the scope and limitations of our program.
And also since this is only a simple for loop parser, We can only have a one-line statement, meaning we don't have to include the two curly braces for a block statement.
|
|
|
|
|
gamer1127 wrote: Is there a way without using regex class?
Of course there is. Regex is a tool, a non-essential tool. Anything you can do with a Regex, you can do without Regex too. It will take more code, it may or may not be more readable, and chances are it will be faster without Regex. See this test[^].
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Your right...hehehehe...Now I'm changing the codes on how to verify the entered string using data structures discussed by our professor (stack and tree). Since there is a Stack Collection in C# I think that would make the work a bit easier. Before I changed all the code(That was only yesterday) I was eager to use the Regex class since it has all that i need. But when I can't find a way on how to verify the entered string using Regex I started to look at the harder way which has a long code.
My only problem now is how to verify the entered string..I'm thinking of the way the infix to postfix works using stack. I think that is similar with what i'll be doing to do the job.
Ah..By the way...Can i use the regex class on splitting the strings only? Then apply the stack and parse tree in verifying the string?
|
|
|
|
|
gamer1127 wrote: Can i use the regex class on splitting the strings only?
Not really as my "not a for loop".Length example indicated.
Furthermore, most programming languages can be parsed by an "LALR" parser, meaning you have to backtrack only one token at most, hence you don't need to have all the input at once, which is fine for huge source files (on which a Regex would probably be very slow).
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Ok then...Can you suggest any good reading materials about parsing that can be found on the web? I already read some in wikipedia but i feel that the explanations there is somewhat incomplete or very hard to understand. I just need to know the basics.
Also should i use the grammar rules(the ones with the terms 'non-terminals' and 'terminals') as my pattern? Or should i use other ways to meet my own criteria in parsing? Right now i'm trying to use the Stack Collection to check the syntax then pass it to a new array, just like how converting from infix to postfix works. What i need are some rules to really come up with that kind of process.
|
|
|
|
|
gamer1127 wrote: Can you suggest any good reading materials about parsing that can be found on the web?
Not really, I learned what I wanted to know about the subject before they invented the internet.
The "Dragon Book" by Aho, Sethi and Ulmann is pretty good. Its real title is "Compilers: Principles, Techniques and Tools" or so.
You can go two ways:
- use a yacc-like program, that reads a BNF description and generates lexer/parser code
- create your own special-purpose lexer/parser, where the methods are probably based on the BNF production rules.
The hardest thing in a parser is parsing expressions; in C-like languages expressions can be almost anything. Now if all you need is something that can find delimiters in a correct and practical code block with only simple expressions, you can skip a lot of stuff. But IMO you do need to handle comments, string literals, and escape characters.
I doubt you will come up with a real good general-purpose C/C++/Java/C# parser in a matter of days...
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Thank You Very Much for your inputs...Now I can continue creating my program..
|
|
|
|
|
No, string.Split won't include the delimiters. It can be done with a Regular Expression. (But you still won't be able to accomplish what you need.)
|
|
|
|
|
I completed a small project on StudentInformation System. I want to deploy in my friend college, Dear Help me, How i develop setup to deploy the software. Regards Iftikhar my emails is iftikharabc@gmail.com
045251
|
|
|
|
|
Well, you can create a deployment project in VS, or you can download a tool like Advanced Installer to help you.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Follow these steps to start with simple deployment setup
1. Add New Project to existing project,
- on add new project window select 'Setup And Deployment' node, on right hand side you will find some of the template
select the 'Setup Project'[or you can select any other according to your convenience]
- Name the project and click OK
- The New project is added to the Solution explorer
- It also opens a 'File System' Editor
- There you will find three tabs
1. Application Folder - Base directory for your application, you should add all the required assemblies by your application here , exe as well
2. User desktop - you want to add Desktop Shortcut add it here
3. User's Program Menu - here you can link in the Start -> program files
- when you add shortcut for step 2 and 3 provide its target as your applications main exe
- now rest is almost same you need to rebuild and this which produces two files under debud/release folder under your setup project directory , these files are nothing but your installbles
I have just provided you with starting steps, you might want to go for some more details like adding icons, status bar icon etc etc
I Would suggest to look on net to explore it more , there are many articles dedicated to this
Reg
Deep
Happy Coding
|
|
|
|
|
Ok I have tried several different ways to get this to work but either i am confused at what causes the build version to increment and how to retreive that value at run time.
Questions:
1) I want the application to increment it's build version automatically with each compile. How is this possible?
-THe Publish Version I can increment when I compile it in the build menu as publish. But the application goes thru the inhouse setup application with C#. So my first question would be how to increment the build version with each compile. As all my results keep bringing back 1.0.0.0.
2) Once I get the build version to auto increment how do I retrieve that version number.
Here is some of what I have tried....
System.Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.;
//System.Version version = System.Reflection.Assembly.GetExecutingAssembly().
System.Diagnostics.Debug.WriteLine(String.Format("{0}.{1}.{2}.{3}", version.Major, version.Minor, version.Revision, version.Build));
//System.Diagnostics.Debug.WriteLine(Application.ProductName.ToString());
//System.Diagnostics.Debug.WriteLine(Application.ProductVersion.ToString());
//System.Diagnostics.Debug.WriteLine(Application.CompanyName.ToString());
//System.Diagnostics.Debug.WriteLine(A
lblAppVersion.Text = (String.Format("{0}.{1}.{2}.{3}", version.Major, version.Minor, version.Revision, version.Build));
System.Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.;
//System.Version version = System.Reflection.Assembly.GetExecutingAssembly().
System.Diagnostics.Debug.WriteLine(String.Format("{0}.{1}.{2}.{3}", version.Major, version.Minor, version.Revision, version.Build));
//System.Diagnostics.Debug.WriteLine(Application.ProductName.ToString());
//System.Diagnostics.Debug.WriteLine(Application.ProductVersion.ToString());
//System.Diagnostics.Debug.WriteLine(Application.CompanyName.ToString());
//System.Diagnostics.Debug.WriteLine(A
lblAppVersion.Text = (String.Format("{0}.{1}.{2}.{3}", version.Major, version.Minor, version.Revision, version.Build));
|
|
|
|
|
1 - the only way I've found to do that, is a post build step that runs an exe that changes the app.config file to increment it
2 - I think what you have should work.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|