|
I'm eager to help when help is honestly needed, but...
This sounds like homework to me.
Beyond that, your requirements are too sketchy to provide any help at all. Maybe they should teach more preparatory courses so you learn how to gather, define, and present requirements before you're allowed to write any code. Who knows? You might find that your real calling in life is being a specifications writer, and you can haunt some other forum instead of trying to get us to help you with homework that a) you're too lazy to do on your own, and b) will most certainly suck in its final form.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: Beyond that, your requirements are too sketchy to provide any help at all. Maybe they should teach more preparatory courses so you learn how to gather, define, and present requirements before you're allowed to write any code.
Too true. I never thought about it before, but you're right, nearly all the homework questions have rubbish specifications/requirements.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
This should get you started.
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;
namespace NeedsCode
{
class Program
{
static void Main(string[] args)
{
throw new NotImplementedException("The program code needs to be implemented.");
}
}
}
"Simplicity carried to the extreme becomes elegance."
-Jon Franklin
|
|
|
|
|
Lol
That one made me laugh.
|
|
|
|
|
That snippet of code does has an esteemed lineage. The only thing keeping it from the hall of fame is a unique modification by Mr. Simmons.
"Simplicity carried to the extreme becomes elegance."
-Jon Franklin
|
|
|
|
|
Great bit of code. Is it Ok to use it (under licence obviously) in a commercial application?
Bob
Ashfield Consultants Ltd
|
|
|
|
|
No problem. I should probably update it with a license of some sort. Let me see what I can dig up.
I keep it on my CP blog if you'd like to add to it.
Scott P.
"Simplicity carried to the extreme becomes elegance."
-Jon Franklin
|
|
|
|
|
*awesome*
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
According to your info ....
Store the information of student in the database and retrieve when user enters the id ,
Simple
|
|
|
|
|
I want to put some data in listBox, then if I want to remove one data, I remove it from the listBox and then overwrite data in listBox to a text file. But it was always failed when it debugged WriteToFile() method below. I dont know why it was failed. It told that "An unhandled exception of type 'System.ObjectDisposedException' occurred in mscorlib.dll"
public void menuItemUn_Click(object sender, EventArgs e)
{
listBoxBlockedNumberDD.Items.Remove(listBoxBlockedNumberDD.SelectedItem);
DeleteFile(Filename);
WriteToFile();
}
public bool DeleteFile(string Filename)
{
try
{
if (File.Exists(Filename))
{
File.Delete(Filename);
return true;
}
else
return true;
}
catch
{
return false;
}
}
public void WriteToFile()
{
while (listBoxBlockedNumberDD.Items != null)
{
using (StreamWriter swb = File.CreateText(Filename))
{
<big>swb.WriteLine(listBoxBlockedNumberDD.Items);</big>
swb.Close();
}
}
}
It was always failed in the Big line(WriteLine). I've tried all kinds of Write to file method but there was nothing worked. Could you tell me where is my mistake?
irsalina [student]
|
|
|
|
|
You have to check a couple of things ....
1) create streamwriter object outside the while loop.
2)and close it after loop is completed.
3)Debug and see I think it would be like "swb.WriteLine(listBoxBlockedNumberDD.Items[index].text); (you may have to use for loop from 0 to item.count)
|
|
|
|
|
Well, I've tried and I guess you meant it this way.
public void WriteToFile()
{
using (StreamWriter swb = new StreamWriter(Filename))
{
for (int i = 1; i <= (listBoxBlockedNumberDD.Items.Count+1); i++ )
{
<big>swb.WriteLine(listBoxBlockedNumberDD.Items[i].ToString());</big> }
swb.Close();
}
}
But now, the Big line threw error :
An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll
Additional information: ArgumentOutOfRangeException
Parameter name: index
How could this happen?
irsalina [student]
|
|
|
|
|
I am trying to compare dates from my C# project file to the dates from my database. What I want to achieve is to check if the same date occured in the database. How do I do this? For example I want to check if DateTime.Now already existed in the database. I am trying to read it from there, however I need only the date, not the time. I have to omit this, because my plan was to convert them to strings and then just compare if they existed already. Can anyone help?
|
|
|
|
|
just call .Date on the date object.
DateTime.Now.Date
Simon
|
|
|
|
|
LOLZ!!! Stupid me! Thanks!
|
|
|
|
|
No worries. It's easily missed if you don't know it's there.
Simon
|
|
|
|
|
The same can also be done by calling DateTime.Today
|
|
|
|
|
Hi,
I have a sql database with data about customers. I made it possible to add/change/remove customers from the gridview.
The customer's data are stored in a sql database. Suppose the user adds/changes/removes a row/cell in my gridview.
How can i update the changes made in the gridview in the datatable?
The idea behind all this is to update the sql database as much as possible 'automatically'.
This is a peace of my code:
dbCommand.CommandText = "SELECT firstName, LastName FROM Customer";
customerAdapter = new SqlDataAdapter(dbCommand.CommandText, connectionString);
reader = dbCommand.ExecuteReader();
// Populate a new data table and bind it to the BindingSource.
customerTable = new System.Data.DataTable();
customerAdapter.Fill(customerTable);
grdcustomerManagement.DataSource = customerTable;
Any idea's?
|
|
|
|
|
Use the same DataAdapter and call its Update method.
|
|
|
|
|
Hi,
I tried that, but it's giving me an error (which is in dutch) about 'delete command'.
I used the update method of the data adapter in the Rowsremoved event of the gridview.
|
|
|
|
|
Ah. You need to create a CommandBuilder object on that DataAdapter so it can fill in the missing SQL insert, delete, and update queries that the adapter needs.
Or, you could just add those Command objects to the DataAdapter yourself.
|
|
|
|
|
Hi,
Any chance you can give me a code sample? I've tried a few i found on the net. But no luck.
|
|
|
|
|
There is a single line of code you add to the creation of the DataAdapter to do this. I cannot believe you didn't find an example that explains this.
dbCommand.CommandText = "SELECT firstName, LastName FROM Customer";
customerAdapter = new SqlDataAdapter(dbCommand.CommandText, connectionString);
Dim cb = new SqlCommandBuilder(customerAdapter);
customerTable = new System.Data.DataTable();
customerAdapter.Fill(customerTable);
|
|
|
|
|
Hi,
I was actually talking about how to update the datatable after a few rows have been removed.
I already got those lines in my application.
I tried updating the datatable with customerAdapter.Update() method.
But it's complaining about a deleteCommand.
So after some rows have been removed from the gridview which i caught in the event handler of the datagridview, how do i update the datatable and update the sql database with the customerAdapter.Update() method?
[EDIT]
Ah never mind, i see what i was doing wrong. I forgot to put the adapter inside the () of the commandbuilder instance.
Thank you, it works perfectly now!
[/EDIT]
modified on Friday, December 12, 2008 2:37 AM
|
|
|
|
|
I am facing problem with ReportViwer during excel file creation. excel format is not proper, it's height is constant. Is there any property by using which i can set the width of excel sheet.
My code is
fileSaveDialog.ShowDialog();
if (fileSaveDialog.FileName != string.Empty)
{
Warning[] warnings;
string[] streamids;
string mimeType;
string encoding;
string extension;
byte[] bytes = this.rvAuditTrail.LocalReport.Render(
type, null, out mimeType, out encoding,
out extension,
out streamids, out warnings);
// this.rvAuditTrail.LocalReport.SetParameters(
//ReportParameter
FileStream fs = new FileStream(fileSaveDialog.FileName,
FileMode.Create);
fs.Write(bytes, 0, bytes.Length);
fs.Close();
}
Truth Is The Simplest !!!!
|
|
|
|