15,902,189 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by shonezi (Top 150 by date)
shonezi
27-Dec-13 5:46am
View
forget I asked, found a solution, and not my credit of course for this idiotic question I had
text1 = text.Replace(@" ", "_");
so stupid for asking while people have serious issues to deal with
shonezi
9-Dec-13 7:38am
View
thank you again
shonezi
9-Dec-13 7:16am
View
sorry for bothering you all , I found solution, this works, thank you all, thank you
foreach (DataGridViewRow row in dgImport.Rows)
{
if (string.IsNullOrEmpty(row.Cells["Potrosnja"].Value.ToString()) == true)
{
row.Cells["Expense"].Value = 0;
}
}
dgImport.Refresh();
shonezi
9-Dec-13 6:55am
View
I can show the code for importing
OpenFileDialog openDialog = new OpenFileDialog();
openDialog.Title = "Select file";
openDialog.Filter = "Excel Sheet(*.xls)|*.xls|All Files(*.*)|*.*";
openDialog.FilterIndex = 1;
openDialog.RestoreDirectory = true;
if (openDialog.ShowDialog() == DialogResult.OK)
{
if (openDialog.FileName != "")
{
textBox1.Text = openDialog.FileName;
cmbExcelSheet.DataSource = GetExcelSheetNames(openDialog.FileName);
foreach (string s in cmbExcelSheet.Items)
{
cmbExcelSheet1.ComboBox.Items.Add(s);
}
}
else
{
MessageBox.Show("Choose Excel sheet path..", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
and GetExcelSheetNames
private String[] GetExcelSheetNames(string excelFile)
{
OleDbConnection objConn = null;
System.Data.DataTable dt = null;
try
{
// Connection String. Change the excel file to the file you
// will search.
String connString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + excelFile + ";Extended Properties=Excel 8.0;";
// Create connection object by using the preceding connection string.
objConn = new OleDbConnection(connString);
// Open connection with the database.
objConn.Open();
// Get the data table containg the schema guid.
dt = objConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
if (dt == null)
{
return null;
}
String[] excelSheets = new String[dt.Rows.Count];
int i = 0;
// Add the sheet name to the string array.
foreach (DataRow row in dt.Rows)
{
excelSheets[i] = row["TABLE_NAME"].ToString();
i++;
}
// Loop through all of the sheets if you want too...
for (int j = 0; j < excelSheets.Length; j++)
{
// Query each excel sheet.
}
return excelSheets;
}
catch (Exception ex)
{
return null;
}
finally
{
// Clean up.
if (objConn != null)
{
objConn.Close();
objConn.Dispose();
}
if (dt != null)
{
dt.Dispose();
}
}
}
shonezi
22-Nov-13 5:03am
View
I have done that, found it :) griff thank you, for help and patience
shonezi
22-Nov-13 3:06am
View
griff I was stupid, your code works and it works great, here is what happened, i used in openfiledialog as you can see, a openFileDialog2.SafeFileName and with it I got just the name of the file while path was defined, but when changing location it doesnt work, I changed the openFileDialog2.SafeFileName to openFileDialog2.FileName; and now it works,
only thing is I need to save documentName just as documentName, I don't want all that path to be saved
but YOUR CODE WORKS< AND I AM SORRY FOR MY IGNORANCE
thank you griff (not the first time you helped me, probably not the last :)
shonezi
22-Nov-13 2:11am
View
sorry, i wasnt online, had to relax my mind :))) the problem is definitelly in line
if (!string.IsNullOrWhiteSpace(path) && File.Exists(path))
File.Exists(path) to be exact, in that the path gets lost of anything but the last item
but I am gonna run debugger now
shonezi
21-Nov-13 11:27am
View
but how to solve the problem griff
shonezi
21-Nov-13 9:45am
View
I placed a breakpoint on string path = item.Text; and the it showed only path of the last item in listview???? while on line
if (!string.IsNullOrWhiteSpace(path) && File.Exists(path))\
it showed the path to first item in listview????
aaaaaaaaaaaaaaaaaa
shonezi
21-Nov-13 9:20am
View
ok, here it is
foreach (ListViewItem item in listOfLoadedFiles.Items)
{
here it shows all items in listview, count is ok
}
but after this line
if (!string.IsNullOrWhiteSpace(path) && File.Exists(path))
{
HERE IT SHOWS ONLY LAST ITEM
byte[] data = File.ReadAllBytes(path);
long length = new FileInfo(path).Length;
string extension = Path.GetExtension(path);
}
shonezi
21-Nov-13 8:49am
View
I am definitelly doing something wrong, it counts alright, maybe it doesnt loops once, ah man I am frustrated
shonezi
21-Nov-13 8:46am
View
I placed path where you said already :) thank you , let me try this what you said about listview
shonezi
21-Nov-13 7:24am
View
it loops only once
shonezi
21-Nov-13 7:21am
View
when I save files from same folder it's ok,all saved, but when saving from different, only the last one in the list is saved
shonezi
21-Nov-13 6:50am
View
is this ok?
shonezi
21-Nov-13 6:50am
View
first did I implented the code corectly
if (listOfLoadedFiles.Items.Count != 0)
{
foreach (ListViewItem item in listOfLoadedFiles.Items)
{
string path = item.Text;
if (!string.IsNullOrWhiteSpace(path) && File.Exists(path))
{
byte[] data = File.ReadAllBytes(path);
long length = new FileInfo(path).Length;
string extension = Path.GetExtension(path);
daData2.InsertCommand = new SqlCommand("INSERT INTO Documents VALUES (@Documents, @patternID, @userID, @documentName, @extension)", cs);
daData2.InsertCommand.Parameters.Add("@Documents", SqlDbType.VarBinary).Value = data;
daData2.InsertCommand.Parameters.Add("@patternID", SqlDbType.NVarChar).Value = patternID.Text;
daData2.InsertCommand.Parameters.Add("@userID", SqlDbType.NVarChar).Value = ID.Text;
daData2.InsertCommand.Parameters.Add("@documentName", SqlDbType.NVarChar).Value = item.Text;
daData2.InsertCommand.Parameters.Add("@extension", SqlDbType.NVarChar).Value = extension;
cs.Open();
daData2.InsertCommand.ExecuteNonQuery();
cs.Close();
}
}
}
else
{
}
shonezi
21-Nov-13 6:37am
View
I did what you suggested but I get only last file in listview added to sql
shonezi
21-Nov-13 5:54am
View
openfiledialog instead of folderbrowser, sorry
shonezi
21-Nov-13 5:52am
View
that's all the code I have
Load files into listview, and save
shonezi
21-Nov-13 5:51am
View
public byte[] ReadDoc(string document)
{
byte[] DocData = null;
DirectoryInfo dirInfo = new DirectoryInfo(document);
foreach (FileInfo f in dirInfo.GetFiles())
{
long DocFileLength = f.Length;
FileStream fs1 = new FileStream(document, FileMode.Open, FileAccess.Read);
BinaryReader br1 = new BinaryReader(fs1);
DocData = br1.ReadBytes((int)DocFileLength);
}
return DocData;
}
private void btnSave_Click(object sender, EventArgs e)
{
if (listOfLoadedFiles.Items.Count != 0)
{
byte[] fileData = null;
foreach (ListViewItem item in listOfLoadedFiles.Items)
{
string extension = Path.GetExtension(item.Text);
fileData = ReadDoc(item.Text);
daData2.InsertCommand = new SqlCommand("INSERT INTO Documents VALUES (@Documents, @patternID, @userID, @documentName, @extension)", cs);
daData2.InsertCommand.Parameters.Add("@Documents", SqlDbType.VarBinary).Value = fileData;
daData2.InsertCommand.Parameters.Add("@patternID", SqlDbType.NVarChar).Value = patternID.Text;
daData2.InsertCommand.Parameters.Add("@userID", SqlDbType.NVarChar).Value = ID.Text;
daData2.InsertCommand.Parameters.Add("@documentName", SqlDbType.NVarChar).Value = item.Text;
daData2.InsertCommand.Parameters.Add("@extension", SqlDbType.NVarChar).Value = extension;
cs.Open();
daData2.InsertCommand.ExecuteNonQuery();
cs.Close();
}
}
else
{
}
shonezi
21-Nov-13 5:49am
View
Deleted
afterwards comes the codes I already posted, that public byte[] and btnSave
shonezi
21-Nov-13 5:47am
View
you right, ok, this is what I am trying to do
I am saving files to sql server,
I have a form with btnSave, listview (listOfLoadedFiles), btnLoadFiles, folderbrowserdialog,
on btnLoadFiles click event I have this code, which works
openFileDialog2.InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.Personal);
openFileDialog2.Title = "Insert document";
openFileDialog2.FileName = "";
openFileDialog2.Filter = "All Files|*.*";
IntPtr hImgSmall; //the handle to the system image list
//IntPtr hImgLarge; //the handle to the system image list
string fName; // 'the file name to get icon from
string fName1;
SHFILEINFO shinfo = new SHFILEINFO();
listOfLoadedFiles.SmallImageList = imageList1;
listOfLoadedFiles.LargeImageList = imageList1;
//openFileDialog1.ShowDialog();
if (openFileDialog2.ShowDialog() != DialogResult.Cancel)
{
listOfLoadedFiles.BringToFront();
listView1.SendToBack();
fName1 = openFileDialog2.SafeFileName;
//Use this to get the small Icon
hImgSmall = Win32.SHGetFileInfo(fName, 0, ref shinfo, (uint)Marshal.SizeOf(shinfo), Win32.SHGFI_ICON | Win32.SHGFI_SMALLICON);
//Use this to get the large Icon
//hImgLarge = SHGetFileInfo(fName, 0,
// ref shinfo, (uint)Marshal.SizeOf(shinfo),
// Win32.SHGFI_ICON | Win32.SHGFI_LARGEICON);
//The icon is returned in the hIcon member of the shinfo struct
System.Drawing.Icon myIcon = System.Drawing.Icon.FromHandle(shinfo.hIcon);
imageList1.Images.Add(myIcon);
//Add file name and icon to listview
listOfLoadedFiles.Items.Add(fName1, nIndex1++);
}
so here I have loaded files to listview and on btnSave need to save them into sql server, when I choose files from same folder everything works fine, because as you said, the path is the same for all files, and the problem you already know
shonezi
21-Nov-13 5:24am
View
thank you Griff, you are right with all your questions. how can I change my ReadDoc code (please help me, I am in dead end)
shonezi
10-Sep-13 4:56am
View
THANK YOU< THANK YOU, THANK YOU!!! it works!!!
shonezi
10-Sep-13 4:45am
View
friend recommended it to me, because on my main form I have bound that string Nesto with datatable (filled with data from sql server) but the data from Nesto has to be avaliable to every form I have, and now I have problem with actually calling the class with that filled data.
shonezi
10-Sep-13 4:29am
View
yes, yes, singleton design pattern, I forgot the name :) I want to use that string on each form which will be filled with data on main form, so with this design pattern I want to have that data on each form, but I dont know how to call it
shonezi
19-Aug-13 6:42am
View
since I am amateur, I will just say thank you both :) :) :) :)
shonezi
19-Aug-13 6:14am
View
:) guess I asked to much ::) :) :) thanks Griff
shonezi
19-Aug-13 6:13am
View
It says Rows don't hold definiton for action Any
shonezi
19-Aug-13 5:40am
View
THANK YOU GRIFF!!! just to ask, is there a possibility to place if question in get set property of the class that I have of the username, just wondering
shonezi
15-Aug-13 8:04am
View
thank you very much :)
shonezi
15-Aug-13 7:26am
View
well I don't know how to call this method on another form and I want to avoid writing entire code on each form. that's my problem actually :)
shonezi
15-Aug-13 4:03am
View
thank you
shonezi
14-Aug-13 2:15am
View
thank you, it was my mistake what I did, I was so totally lost I havent even noticed I was making new question instead should have continued on this one.
shonezi
13-Aug-13 8:27am
View
I am sorry, this is what I am trying to do, I have table variables in Sql Server, with columns Main, Data and DataDetails
I want to get values from those columns by specific ID in strings on my form. I dont want to bind textboxes to it but I want to in sort of speak bind them with strings, and I dont know what to do
shonezi
13-Aug-13 7:56am
View
obviously I am stupid. that's why I posted here my problem, I am trying to get @Main, @Data, and @DataDetails values to those strings up there
shonezi
13-Aug-13 6:35am
View
I tried this, but it's all empty
SqlCommand command = new SqlCommand("SELECT * from Variables WHERE ID = @ID", cs);
command.Parameters.Add("@ID", SqlDbType.Int);
command.Parameters["@ID"].Value = Main.pattern3.Text;
cs.Open();
command.ExecuteNonQuery();
command.Parameters.AddWithValue("@Main", main);
command.Parameters.AddWithValue("@Data", amenu);
command.Parameters.AddWithValue("@DataDetails", amenu1);
command.Parameters.AddWithValue("@DataActivities", amenu2);
command.Parameters.AddWithValue("@DataHistory", amenu3);
command.Parameters.AddWithValue("@Storage", bmenu);
command.Parameters.AddWithValue("@StorageDetails", bmenu1);
command.Parameters.AddWithValue("@StorageActivities", bmenu2);
command.Parameters.AddWithValue("@StorageHistory", bmenu3);
cs.Close();
main, amenu, amenu1, amnenu2, and so own are strings, but I get all empty values
shonezi
7-Aug-13 7:17am
View
my bad, its working, i made a mistake on button click which triggers this code, sorry
shonezi
22-Jun-13 11:25am
View
now I get error on im = Bitmap.FromStream(ms) Cannot implicitly convert System.DrawingImage to User.Image
and on image1.Image = im I get cannot implicitly convert User.Image to System.drawing.Image :D :D :D
shonezi
12-Jun-13 12:43pm
View
it doesnt work
shonezi
31-May-13 6:22am
View
thank you, sorry for stupid question, but my brain has left me this morning :P
shonezi
13-Apr-13 16:41pm
View
thank you :)
shonezi
7-Apr-13 5:08am
View
THANK YOU!!!!!!!!!! I thought something like that might be the issue but NO CLUE HOW TO SOLVE IT.. THANK YOU!!!!
shonezi
28-Dec-12 7:17am
View
things is I dont get exception message, it just stands that, with nothing happening
shonezi
27-Nov-12 7:04am
View
I just added rct.Width = 240; sorry for the trouble and asking stupid questions
shonezi
22-Nov-12 5:47am
View
yes mate, sorry I didnt reply,thank you again
shonezi
21-Nov-12 12:56pm
View
I found a problem, code works, its something I did that makes those columsn show up:))
shonezi
21-Nov-12 12:37pm
View
50 percent :)))
shonezi
21-Nov-12 12:37pm
View
I have modified my code to this and it works 500 percent because half of the columns that are hidden in dgv are hidden in exported xml, BUT I have a strange thing also shownand that is that I have 17 columns which are hidden but headertext also gets exported???????and I dont know what to do
DataTable dt = new DataTable();
dt.TableName = "MyTable";
foreach (DataGridViewColumn col in dg1.Columns)
{
dt.Columns.Add(col.HeaderText);
}
foreach (DataGridViewRow gridRow in dg1.Rows)
{
if (gridRow.IsNewRow)
continue;
DataRow dtRow = dt.NewRow();
for (int i = 0; i < dg1.Columns.Count; i++)
if (dg1.Columns[i].Visible)
dtRow[i] = (gridRow.Cells[i1].Value == null ? DBNull.Value : gridRow.Cells[i].Value);
dt.Rows.Add(dtRow);
}
DataSet ds = new DataSet();
ds.Tables.Add(dt);
ds.WriteXml(saveFileDialog1.FileName);
shonezi
21-Nov-12 12:19pm
View
I did mate and I cant get it running on this code :)))
shonezi
21-Nov-12 9:30am
View
I have this
for (int i = 0; i < dg1.Columns.Count; i++)
{
if (dg1.Columns[i].Visible)
{
//code
}
}
but its not working
shonezi
21-Nov-12 8:45am
View
how to do this???
shonezi
20-Nov-12 8:35am
View
I also added your addition to code after foreach (DataGridViewRow dr in dg1.Rows)
thank you a lot!!!!!!!!!!
shonezi
9-Nov-12 8:06am
View
thank you, works great
shonezi
6-Nov-12 15:29pm
View
aaaa mousedown, and i was on mouseclick...thanks a lot mate, thank you 5+ :)))
shonezi
6-Nov-12 15:23pm
View
I tried with flowlayoutpanel and it worked fine, maybe it's because of the richtextbox that it doesnt work
shonezi
6-Nov-12 15:16pm
View
I tried this but nothing again
shonezi
5-Nov-12 5:11am
View
it says on ListItem that I am missing a directive or assembly reference????
shonezi
17-Oct-12 14:35pm
View
I wonder if maybe the problem is that the mailFrom address that I use to send mail from is not used on this PC, or better said it is not created account in outlook on THIS PC that I am on
shonezi
17-Oct-12 14:29pm
View
I found this code on net , somebody also had the same problem
string attachments = attachment.Text;
char[] separator = {';'};
string[] myattach;
myattach = attachments.Split(separator);
if (attachments != null)
if (attachments.Length != 0)
foreach (string str in myattach)
{
if (str.Trim() != "")
{
mail.Attachments.Add(new Attachment(Path.GetFullPath(str)));
}
}
and on THIS ONE I get failure in sending mail????
shonezi
17-Oct-12 14:17pm
View
system.mail.attachment.attachment(string) has some invalid arguments
shonezi
17-Oct-12 14:16pm
View
with additional one, it says on (new Attachment(attach)) part that there are some invalid arguments
shonezi
17-Oct-12 14:15pm
View
sorry, I did something, i dont know what, but anyway when I made the change you suggested it still says the same error
shonezi
17-Oct-12 14:07pm
View
I get failure in sending mail
shonezi
3-Oct-12 2:14am
View
I misstyped, and you are write, thank you
shonezi
24-Sep-12 3:32am
View
Thanks Santhos!!! I am such a begginer :)
shonezi
21-Sep-12 7:33am
View
THANK YOU VERY MUCH DYLAN, I have been going lef and right , up and down busting my head with this, thank you, thank you!!!!!
shonezi
19-Sep-12 8:20am
View
Deleted
I have managed to overcome this issue in a totally different manner, on datagridview_cellclick event I placed
int i;
i = dataGridView1.SelectedCells[0].RowIndex;
ID.Text = dataGridView1.Rows[i].Cells["ID"].Value.ToString();
and it works when I click row it does what I want, but I now have this problem, when i change selection of rows with up and down arrows the cellclick event doesnt work
shonezi
10-Sep-12 8:07am
View
same error again, whats wrong Mohamed with this, it should work
shonezi
10-Sep-12 7:12am
View
nothing happens
shonezi
3-Sep-12 8:54am
View
good idea
shonezi
31-Aug-12 16:18pm
View
thank you, and thank you TR and Wes Day :))
shonezi
31-Aug-12 14:51pm
View
well, you are totally right so I did this, I placed all of the code with stopwatch to Shown event, to raise it just once on form load and its 0 miliseconds, works fast. maybe this is ok, is it?
shonezi
31-Aug-12 14:38pm
View
I am a little lost on this one
shonezi
31-Aug-12 14:31pm
View
how to do that??
shonezi
31-Aug-12 14:30pm
View
yeah you are right, all of you, I am reformatting all the time, how to stop this and make it just once
shonezi
31-Aug-12 14:19pm
View
I did what you suggested, I get around 300 miliseconds response at start, but when it finishes populating it shows 6. problem is also that when I scroll up and down the datagridview it is also slow
shonezi
31-Aug-12 13:55pm
View
this is great, I am currently trying to learn WPF but really am just a begginer. thank you
shonezi
27-Aug-12 14:16pm
View
Thank you both :)))
shonezi
27-Aug-12 14:13pm
View
THank you very much, very helpfull, thank you again
shonezi
27-Aug-12 14:13pm
View
I copied it but still the same, and I thank you a lot friend, Sourav Sarkar-SS managed to solve it, basically the same code as yours with modificationn but many thanks to you as well
shonezi
27-Aug-12 14:03pm
View
same thing, empty spaces are still there
shonezi
27-Aug-12 14:03pm
View
still the same
shonezi
27-Aug-12 13:53pm
View
this works, just one thing, I have empty spaces between rows in listbox like this
empty
1
empty
2
empty
while it should be
1
2
shonezi
27-Aug-12 13:42pm
View
this code is for passing listbox to textbox but I need textbox to listbox but the problem is I have in textbox this ,1,2, and I want in listbox to add 1 and under it in second row of listbox 2
shonezi
27-Aug-12 13:38pm
View
I have no code
shonezi
27-Aug-12 8:13am
View
THANK YOU!!!!!!!
shonezi
27-Aug-12 7:46am
View
daPattern.SelectCommand = new SqlCommand("SELECT * from Pattern", cs);
dsPattern.Clear();
daPattern.Fill(dsPattern);
PatternBS.DataSource = dsPattern.Tables[0];
listpatternID.DataSource = PatternBS;
listpatternID.DisplayMember = "ID";
shonezi
27-Aug-12 7:35am
View
I did this but nothing, again the same
shonezi
27-Aug-12 7:32am
View
it says
object does not contain a definition for text and no extension method text accepting first argument of type object could be found (are you missing a using directive or assembly reference?)
I have these using directives
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Configuration;
using User.Properties;
using System.Data.SqlClient;
shonezi
24-Aug-12 2:52am
View
problem is I know nothing about wpf, I know I know, I am just another fool trying to get something without basic knowledge of about it and it's frustrating to deal with those like me. but this xaml is totaly unknown to me for now, I just need the code for binding textbox to sql server table column and that's it.
shonezi
20-Aug-12 8:31am
View
and this also worked, thank you all
shonezi
20-Aug-12 8:31am
View
I dont know what I did, but now it works :)
shonezi
20-Aug-12 8:16am
View
this su....cks.....again the same thing
shonezi
20-Aug-12 8:14am
View
ok, I am going from the beggining.....I am adding DataSet
shonezi
20-Aug-12 8:11am
View
well, thats the problem, I dont how, because I wrote it JUST THE SAME when it worked, so I am buffled
shonezi
20-Aug-12 8:03am
View
how to solve this now
shonezi
20-Aug-12 8:01am
View
doesnt exist??? but how
shonezi
20-Aug-12 8:01am
View
first time when I did this when it worked and I typed DataReport it was normally in black color of font and after dot Clear could be typed
shonezi
20-Aug-12 7:56am
View
DataReport is DataSet I created, its there in solution tree with extension xsd
shonezi
20-Aug-12 7:55am
View
that's the problem, it did work but then I made the exact same code, everything and now when I type DataReport it highlights and I have no extension Clear on it, I cant type it???
shonezi
20-Aug-12 7:51am
View
I have no idea what is that
shonezi
20-Aug-12 7:51am
View
it says an object reference is required for non-static field, method or property System.Data.DataSet.Clear();
shonezi
20-Aug-12 7:46am
View
it says I dont have object reference, but it worked before????
shonezi
20-Aug-12 7:44am
View
I restarted, same thing, I am puzzled, it worked now it doesnt, and I have done everything the same, maybe it is something in properties
shonezi
27-Jul-12 7:25am
View
I have a windows form application in C#, the code on form load is
daActivity.SelectCommand = new SqlCommand("SELECT * from DataActivity", cs);
dsActivity.Clear();
daActivity.Fill(dsActivity);
ActivityBS.DataSource = dsActivity.Tables[0];
dg.DataSource = ActivityBS;
this.dg.Sort(this.dg.Columns["DataInputID"], ListSortDirection.Descending);
where dg is datagridview that I have on my form, as you can see I fill dg from Sql Server, and it is sorted by first column in dg called DataInputID
this DataInputID is the same for multiple rows and I want to group them, being able to expand that group
I have looked on the google and found some solutions but was unable to implement them into my form, because most of those solutions are for asp.net
while I have simple basic windows form application that pulls data from Sql Server
shonezi
27-Jul-12 5:45am
View
unfortunately I am working in windows form application, not WPF
shonezi
25-Nov-11 7:20am
View
no, nothing, I do an export but those columns that I made invisible
are exported also
shonezi
25-Nov-11 7:07am
View
I tried but its not working
shonezi
11-Aug-11 7:03am
View
it's not working properly, it doesnt show contents of each cell that I hover over
shonezi
11-Aug-11 7:03am
View
I dont want to type in text of tooltip, I want that tooltip shows text which is in the cell
shonezi
27-Jun-11 6:24am
View
my bad , it works with loaded binding source, not the one I made myself. THANKS!!!!
shonezi
25-Jun-11 10:09am
View
I did put the brackets, I saw it but still the same message
shonezi
24-Jun-11 16:06pm
View
it says it cant intepret token on position 14 and 26????
shonezi
21-Jun-11 6:26am
View
works!!!!!!!!!!! THANKS A LOT MATE!!!!!!!!!
shonezi
21-Jun-11 6:06am
View
ok, how do I do that, I mean the code?
shonezi
19-May-11 5:11am
View
this is ok but I always get zero at the end because newVal = 0, it doesnt change to to next number upon adding data
shonezi
9-May-11 7:27am
View
I did put it already mz username string inside it, I just refered to textbox as example also :)))
shonezi
9-May-11 6:42am
View
it doesnt work
shonezi
9-May-11 6:04am
View
it says I cant put argument as textbox1.Text in login code.
shonezi
9-May-11 5:48am
View
Hello, thanks for the answer, but I have a problem, login form runs on application run so only when I type in correct username and password does the start form opens up, and on this start form I have textbox where I want to see logged in user. I did what u told me but nothing happened, I still don't see the username in textbox????
shonezi
26-Feb-11 5:56am
View
I did this but it says that GlobalState doesnt exist in current context
shonezi
25-Feb-11 14:25pm
View
sorry I havent explained better, I have login form with textbox username and I have main form with also textbox username, in this main form I want to see username that is logged in, I have done what you said and the code is ok, just I need how to see on main form in textbox the name of logged user
tthanks
shonezi
25-Feb-11 14:20pm
View
I did what you said, but tell me this txtUserName.Text refers to login form or on another form where I have textbox in which I want to see who is logged on
shonezi
25-Feb-11 12:53pm
View
I am new to visual studio, can you if you don't mind be little specific in code please
shonezi
25-Feb-11 12:35pm
View
when logged in it opens another form, not showdialog but
form2 frm = new form2();
frm.Show();
that code
shonezi
18-Feb-11 12:11pm
View
on wrong user,pass
opens window it says
ATMDataSet.users.KorisnikLozinkaString(Korisnik,Lozinka) could not be previewed.
Parameter ?_1 has no default value.
shonezi
18-Feb-11 12:04pm
View
well it returns row with the proper user, I mean it works because if I type wronf entry it doesnt return anything
shonezi
18-Feb-11 11:56am
View
public virtual global::System.Nullable<int> KorisnikLozinkaString(string Korisnik, string Lozinka) {
global::System.Data.OleDb.OleDbCommand command = this.CommandCollection[1];
if ((Korisnik == null)) {
command.Parameters[0].Value = global::System.DBNull.Value;
}
else {
command.Parameters[0].Value = ((string)(Korisnik));
}
if ((Lozinka == null)) {
command.Parameters[1].Value = global::System.DBNull.Value;
}
else {
command.Parameters[1].Value = ((string)(Lozinka));
}
global::System.Data.ConnectionState previousConnectionState = command.Connection.State;
if (((command.Connection.State & global::System.Data.ConnectionState.Open)
!= global::System.Data.ConnectionState.Open)) {
command.Connection.Open();
}
object returnValue;
try {
returnValue = command.ExecuteScalar();
}
finally {
if ((previousConnectionState == global::System.Data.ConnectionState.Closed)) {
command.Connection.Close();
}
}
if (((returnValue == null)
|| (returnValue.GetType() == typeof(global::System.DBNull)))) {
return new global::System.Nullable<int>();
}
else {
return new global::System.Nullable<int>(((int)(returnValue)));
shonezi
18-Feb-11 11:52am
View
namespace ATM
{
partial class Login
{
///
/// Required designer variable.
///
private System.ComponentModel.IContainer components = null;
///
/// Clean up any resources being used.
///
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.usersTableAdapter2 = new ATM.ATMDataSetTableAdapters.usersTableAdapter();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(182, 69);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(44, 13);
this.label1.TabIndex = 0;
this.label1.Text = "Korisnik";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(182, 96);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(44, 13);
this.label2.TabIndex = 1;
this.label2.Text = "Lozinka";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(244, 66);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 20);
this.textBox1.TabIndex = 2;
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(244, 93);
this.textBox2.Name = "textBox2";
this.textBox2.PasswordChar = '*';
this.textBox2.Size = new System.Drawing.Size(100, 20);
this.textBox2.TabIndex = 3;
this.textBox2.UseSystemPasswordChar = true;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("Arial", 12F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label3.Location = new System.Drawing.Point(137, 275);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(276, 18);
this.label3.TabIndex = 41;
this.label3.Text = "SEKTOR ZA TELEKOMUNIKACIJE";
//
// button1
//
this.button1.Font = new System.Drawing.Font("Arial", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button1.Location = new System.Drawing.Point(185, 136);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(159, 32);
this.button1.TabIndex = 42;
this.button1.Text = "OTVORI";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
shonezi
18-Feb-11 11:48am
View
this is form called Login with two textboxes and button, I have another form which I want to to open when typing in proper username and password click on button to open. I am new to C# and visual studio.
namespace ATM
{
public partial class Login : Form
{
public Login()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
dynamic login = this.usersTableAdapter2.KorisnikLozinkaString(textBox1.Text, textBox2.Text);
{
if (login == null)
MessageBox.Show("Wrong entry");
}
}
}
}
shonezi
18-Feb-11 11:41am
View
SELECT COUNT(*) AS Result, Korisnik AS KorisnikInput, Lozinka AS LozinkaInput
FROM users
GROUP BY Korisnik, Lozinka
HAVING (COUNT(*) = 1) AND (Korisnik = ?) AND (Lozinka = ?)
shonezi
12-Feb-11 5:36am
View
Ok I have done this:
My datasource is accdb 2007 database, in it I have a table called users with simple 3 columns: ID, username, password
I open dataset which was created based on datasource
and I built query
SELECT COUNT(*) AS Result, username AS usernameInput, password AS passwordInput
FROM users
GROUP BY username, password
HAVING (COUNT(*) = 1) AND (username = ?) AND (password = ?)
and this works fine
then on login form in code of button which has to be clicked for logging in after correct input of username and password I have this:
private void button1_Click(object sender, EventArgs e)
{
dynamic login = this.usersTableAdapter2.usernamepasswordString(textBox1.Text, textBox2.Text);
usernamepasswordString is the name of the query I first mentioned nad textBox1 and textBox2 are two textboxes on login form, textBox1 is for input username and textBox2 is for input password
and here I am stuck because I want when clicked on this button to open another form or to start working on application better said but I am stuck with the code, any help
another froms name is ATM
shonezi
7-Feb-11 12:50pm
View
I got it
SELECT RB, Bankomat, Datum_otvaranja, Vreme_prijave, ProView_vreme, Naziv_dogadjaja, Preduzeta_mera, Napomena FROM dnevni_izvestaj
WHERE Datum_otvaranja BETWEEN ? And ?
and I joined code on datetimepicker
DateTime Datum_otvaranja = dateTimePicker1.Value;
DateTime Datum_otvaranja1 = dateTimePicker2.Value;
because in SQL I have put question mark ? that made Datum_otvaranja and Datum_otvaranja1
anyway , it works, thanks a lot mate
shonezi
7-Feb-11 5:29am
View
OK I did this
SELECT RB, Bankomat, Datum_otvaranja, Vreme_prijave, ProView_vreme, Naziv_dogadjaja, Preduzeta_mera, Napomena FROM dnevni_izvestaj
WHERE Datum_otvaranja BETWEEN ? And ?
and I got what I wanted but I just need to put code on the button to generate report and I am in a jam
shonezi
7-Feb-11 3:39am
View
I am still in a jam, maybe I didn't explain it well, this is what I want: I have a table called dnevni_izvestaj, in that table I have a date column called Datum_otvaranja, this table is OLE DB from access 2007 as datasource. I have a form with reportviewer, two datetimepickers and a button, I have dataset with imported table dnevni_izvestaj on it. I choose dates from those datetimepickers and then clicking on button to open report based on chosen dates. sql is in dataset and I am stcuk, I am a newbie in visual studio, but I worked in access although no help with access sql in visual :)
shonezi
6-Feb-11 16:50pm
View
I have trouble with this parameter queries cause code from above is in dataset from which report was made
shonezi
6-Feb-11 9:38am
View
I will look on it later, and let you know. thanks a lot
shonezi
6-Feb-11 9:07am
View
It's OleDb connection, so how does the code should look like?
shonezi
31-Jan-11 11:35am
View
last question and then I am gone :)) defining date parameters , I need help on code. so I have two dateTimePickers: dateTimePikcer1 and dateTimePicker2, how does this code looks like
dateTimePicker1.Value
dateTimePicker2.Value
????
shonezi
31-Jan-11 10:40am
View
ok, just one thing, those two date parameters are dateTimePikcers???
shonezi
31-Jan-11 10:29am
View
ah sorry, now I know what you meant, I do have designed RDL but I just want to display those data by dates when I choose which one, I mean between dates
shonezi
31-Jan-11 10:18am
View
I know I have put to much questions and perhaps you already are annoyed by me, but if I only have this what I have how can I make this work, what would you do, step by step if you don't mind.
one table, two datetimepickers, button.... choosing from date to date clivk on buton opens report, how would you do it easiest way
shonezi
31-Jan-11 10:12am
View
I can't see report Dtat pane in Visual studio 2010 on which I am working, and I work in C#
shonezi
31-Jan-11 6:12am
View
basically I have
table DailyReport with columns RB, Bankomat, DatInput
and I everyday write some data in and have dates
and I want report to open generated by dates, that's it
shonezi
31-Jan-11 5:59am
View
yes, I used dataset and assign them to report, and no I am not using SSRS report designer. and overiding button click on reportviewer I don't know what it means but I just have one button witht he code above in previous comment
shonezi
31-Jan-11 5:41am
View
ok1.I have table DailyReport
2.Dataset1 in which query is:
SELECT RB, Bankomat, DateInput, FROM DailyReport
WHERE DateInput BETWEEN @FromDate AND @ToDate
3. I use this Dataset1 for making Report1.rdlc which I use for reportviewer for generating report
4. above reportviewer is 2 dateTimePickers, one from and other to date, and the Button for generating report when I choose dates
5. in Button is code: private void button1_Click(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'DataSet1.DailyReport' table. You can move, or remove it, as needed.
this.DailyReportTableAdapter.Fill(this.DataSet1.DailyReport);
this.reportViewer1.RefreshReport();
I hope I have explained a little better how it looks like, I am quite new, but as I said , trying to learn :))
shonezi
31-Jan-11 5:14am
View
forgive me for asking but what does that mean to use query in SP or parameterized query???
shonezi
31-Jan-11 4:57am
View
I did this but when I click on finish I get error in WHERE clause near '@', so when I try preview data I get nothing, no parameters
shonezi
31-Jan-11 3:51am
View
I just can't get fill adapter to work for the table to generate report when I choose date in those two datetime controls because those datetime controls are not bound to the table. I am new to C# but eager to learn, I have a report, two datetime controls, one button, a table with primary column DateInput with dates, and I want when I choose dates and click on the button to generate report only for choose dates. I know I have to put some code in SQL for the report but I don't know how because those datetime controls are not part of the table
Show More