|
There is code for UpdateDatabase
public void UpdateDatabase(System.Data.DataSet ds)
{
System.Data.SqlClient.SqlCommandBuilder cb = new System.Data.SqlClient.SqlCommandBuilder(da_1);
cb.DataAdapter.Update(ds.Tables[0]);
}
|
|
|
|
|
Are you sure that the DataAdapter is correctly linked to the DataSet ?
|
|
|
|
|
I think that Dataset is correctly connected to a Dataadapter , because in form I see data from database. What would happen when a Dataadapter is incorrectly connected to a DataSet ?
|
|
|
|
|
If they are not properly linked then the updates will most likely fail, although I would expect to see an exception in such a case. It is difficult to be certain what the issue is, although you may like to try contacting the person who provided the sample code.
|
|
|
|
|
Put a breakpoint on
cb.DataAdapter.Update(ds.Tables[0]);
then select "ds.Tables[0]" and right-click. Choose quick watch. In here you can drill down on the object. Check if the change you made is there. if not, my guess is that you'll need to set some property in the designer or when creating the Dataset/DataAdapter in code.
Hope this helps.
|
|
|
|
|
From the last paragraph of said tutorial;
(If the new record doesn't appear when you restart, go back to Design Time. In the Solution Explorer, click on your Database under Resources to select it. Now have a look at the Properties window below the Solution Explorer. Locate a property called Copy to Output Directory. It has three settings: Do not copy, Copy always, and Copy if newer. If your database is not updating, try either Copy if newer or Copy always.)
I did not see any update-statements, nor an implementation of "objConnect.UpdateDatabase(ds)". I suggest you look for a different tutorial. For one, I think that databinding is better explained on MSDN[^], second because databinding hides a lot of the (boring) details.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
|
I have large panel which contains numbers of controls, I want to export that panel and all the controls to the PDF by using iTextSharp. Plz help
|
|
|
|
|
Member 9852108 wrote: Plz help Please provide proper details of your problem, and exactly what help you need.
|
|
|
|
|
NEED HELP!!
My project is 'digital steganography' in which we are doing image, audio and video steganography. We taken help from CodeProject, image is working properly but in audio steganography im stucking somewhere...
here is the code snippet:
WaveStream.cs
private void CopyHeader(Stream destinationStream)
{
BinaryReader reader = new BinaryReader(m_Stream);
BinaryWriter writer = new BinaryWriter(destinationStream);
if (CopyChunk(reader, writer) != "RIFF")
throw new Exception("Invalid file format");
writer.Write( reader.ReadInt32() ); // File length minus first 8 bytes of RIFF description
if (CopyChunk(reader, writer) != "WAVE")
throw new Exception("Invalid file format");
if (CopyChunk(reader, writer) != "fmt ")
throw new Exception("Invalid file format");
int len = reader.ReadInt32();
if (len < 16){ // bad format chunk length
throw new Exception("Invalid file format");
}else{
writer.Write(len);
}
m_Format = new WaveFormat(22050, 16, 2); // initialize to any format
m_Format.wFormatTag = reader.ReadInt16();
m_Format.nChannels = reader.ReadInt16();
m_Format.nSamplesPerSec = reader.ReadInt32();
m_Format.nAvgBytesPerSec = reader.ReadInt32();
m_Format.nBlockAlign = reader.ReadInt16();
m_Format.wBitsPerSample = reader.ReadInt16();
//copy format information
writer.Write( m_Format.wFormatTag );
writer.Write( m_Format.nChannels );
writer.Write( m_Format.nSamplesPerSec );
writer.Write( m_Format.nAvgBytesPerSec );
writer.Write( m_Format.nBlockAlign );
writer.Write( m_Format.wBitsPerSample );
// advance in the stream to skip the wave format block
len -= 16; // minimum format size
writer.Write( reader.ReadBytes(len) );
len = 0;
/*while (len > 0)
{
reader.ReadByte();
len--;
}*/
// assume the data chunk is aligned
while(m_Stream.Position < m_Stream.Length && CopyChunk(reader, writer) != "data")
;
if (m_Stream.Position >= m_Stream.Length)
throw new Exception("Invalid file format");
m_Length = reader.ReadInt32();
writer.Write( m_Length );
m_DataPos = m_Stream.Position;
Position = 0;
}
_______________________________________________________
in above snippet im getting exception thrown from here:
if (m_Stream.Position >= m_Stream.Length)
throw new Exception("Invalid file format");
im doing it for .wav file, please help.
Krrish8891
|
|
|
|
|
Has it occurred to you that when you drop out of the while loop above that line then m_Stream.Position will be equal to the length of the stream ... it's why you drop out of the loop
|
|
|
|
|
hi i want to know , how i can get each page total rows . using itextsharp dll .
i want to put all of my code onStartPage
public class MyPdfPageEventHelpPageNo : iTextSharp.text.pdf.PdfPageEventHelper
{
public override void OnStartPage(PdfWriter writer, Document document)
{
}
}
ty for any help
|
|
|
|
|
Is it a PDF you are reading, or one that you are creating, that you want the page count for?
If you are reading a PDF you could get gate the page into a string(this example will extract page 1).
string page = PdfTextExtractor.GetTextFromPage(new PdfReader(fileName), 1,new SimpleTextExtractionStrategy());
Then count the new line characters in the string.
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
modified 2-May-14 8:11am.
|
|
|
|
|
No , the pdf that im creating.
|
|
|
|
|
In which case I guess you have answered your own question.
If you are creating it yourself you will be inserting lines, therefore you will know how many lines you have inserted into the PDF.
Or to put it another way - if you are creating the PDF why is it that you don't know how many lines are in the PDF?
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
|
|
|
|
|
i know how many lines it'll write on pdf file but bcz of the different height between lines i can't figure out how many line first page can contain , and how many other lines second page can contain .
let's say i have 200 line with different height , how should i know how many page it takes . it sure that it depends on the line height .
|
|
|
|
|
There are a number of ways to do this – what I did, as I knew that I had the same font size on the page , was to print 100 lines at that font size to see how many pages that took.
If you are using different font sizes then this will probably not work for you – at which point I would suggest google.
What I would look for is to see if anyone has a formula for calculating the line height – there will be a number of considerations such as DPI that may need to be taken into account.
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
|
|
|
|
|
Hi,
we are developing an mobile application and we have used WCF service to fetch SQL Server data through online.
We are trying to authenticate each WCF Service call(server) by passing headers from client (mobile application). For this we have generated a token and passed the same in headers of each client call.
We have stored the tokens in HttpRuntime.Cache. But after few minutes [in idle mode] the cache entry is cleared.
Note: If continuously server and client communicates, it works perfectly.
Below is our WCF service Cache code:
HttpRuntime.Cache.Insert(key, Token, null, DateTime.Now.AddHours(1),Cache.NoSlidingExpiration);
if some other better solution available, kindly suggest how we can save the tokens alone in server and authenticate the same from client for each service call.
|
|
|
|
|
|
Okay, so I'm a self-taught programmer and have been brushing up on all the 'boring' bits that CS students do that most of us self-taught ignore. Things like Algorithms and Data Structures (particularly). So I found a nice exercise book that explains how algorithms work, but then leaves the implementation to the reader.
This works well for me as I'm the kind of person for whom knowledge 'sticks' better if I can "figure it out for myself".
So, I've just finished the Chapter on Sorting and quite easily managed to implement working Bubble Sort, Radix Sort, Mergesort etc. I really struggled getting Quicksort to work though - lots of out of bounds errors that I found hard to track down. So, now I do have it working - I'm wondering whether I just set about coding the algorithm (I'm using C#) the wrong way in the first place.
So, my question, I'll post my code below, and I'd really appreciate it if you guys could tell me (mentor style I guess) how I could have done a better job if I did it again. What I don't want is a long discussion of "you chose a silly pivot value", remember I implemented this from an exercise and that told me explicitly to use the left-most value of each sub-array as the pivot for each partition.
So, here's the code that basically creates the object and calls the sort method:
class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Exercise 24.10 - Quicksort\n\n");
Quicksort sort = new Quicksort(12);
Console.WriteLine("Unsorted: {0}\n", sort);
sort.Sort();
Console.WriteLine("\n Sorted: " + sort);
Console.Write("\nPress any key to continue . . . ");
Console.ReadKey(true);
}
}
and here's the object that implements the Quicksort & the partitioning:
class Quicksort
{
private int[] data;
private Random rng = new Random();
public Quicksort(int size)
{
data = new int[size];
for(int i=0; i<data.Length;i++)
data[i]=rng.Next(0,100);
}
public void Sort()
{
recSort(0, data.Length-1);
}
private void recSort(int left, int right)
{
if(left<right) {
int pivot = Partition(left, right);
recSort(left, pivot-1);
recSort(pivot+1, right);
}
}
private int Partition(int left, int right)
{
int i=left;
int j=right+1;
int pivot = data[left];
while(i<j) {
do {
j--;
} while (data[i]<data[j]);
if(i<j)
Swap(i,j);
do {
i++;
} while (data[j]>data[i]);
if(i<j)
Swap(i,j);
}
return j;
}
private void Swap(int i, int j)
{
int temp=data[i];
data[i]=data[j];
data[j]=temp;
}
public override string ToString()
{
StringBuilder temp = new StringBuilder((data.Length*6)+1);
for(int i=0; i<data.Length; i++)
temp.AppendFormat("[{0:00}] ", data[i]);
return temp.ToString();
}
}
Sample output (with debugging turned on) looks like this:
Exercise 24.10 - Quicksort
Unsorted: [64] [48] [79] [43] [75] [54] [81] [94] [75] [66] [57] [61]
SW 64/61: [61] [48] [79] [43] [75] [54] [81] [94] [75] [66] [57] [64]
SW 79/64: [61] [48] [64] [43] [75] [54] [81] [94] [75] [66] [57] [79]
SW 64/57: [61] [48] [57] [43] [75] [54] [81] [94] [75] [66] [64] [79]
SW 75/64: [61] [48] [57] [43] [64] [54] [81] [94] [75] [66] [75] [79]
SW 64/54: [61] [48] [57] [43] [54] [64] [81] [94] [75] [66] [75] [79]
SW 61/54: [54] [48] [57] [43] [61] [64] [81] [94] [75] [66] [75] [79]
SW 54/43: [43] [48] [57] [54] [61] [64] [81] [94] [75] [66] [75] [79]
SW 57/54: [43] [48] [54] [57] [61] [64] [81] [94] [75] [66] [75] [79]
SW 81/79: [43] [48] [54] [57] [61] [64] [79] [94] [75] [66] [75] [81]
SW 94/81: [43] [48] [54] [57] [61] [64] [79] [81] [75] [66] [75] [94]
SW 81/75: [43] [48] [54] [57] [61] [64] [79] [75] [75] [66] [81] [94]
SW 79/66: [43] [48] [54] [57] [61] [64] [66] [75] [75] [79] [81] [94]
SW 75/75: [43] [48] [54] [57] [61] [64] [66] [75] [75] [79] [81] [94]
Sorted: [43] [48] [54] [57] [61] [64] [66] [75] [75] [79] [81] [94]
|
|
|
|
|
Hi all,
In below code, im opening a file selection dialog and then im asking if the user needs to delete a previous file with some data. When i say "Yes" to that the File.Delete() code doesn't work (don't delete the file) and nor gives a exception. What i'm doing here wrong, please?
Thanks.
if (selResult == DialogResult.OK)
{
DialogResult dr = MessageBox.Show("Do you want to delete previous data?", "Delete?", MessageBoxButtons.YesNo);
if (dr == DialogResult.OK)
{
try
{
File.Delete("data.txt");
}
catch(IOException copyError)
{
MessageBox.Show(copyError.ToString());
}
StreamWriter sw0 = new StreamWriter("data.txt", true);
sw0.Close();
}else if(dr == DialogResult.No)
{
MessageBox.Show("Cancelled");
return;
}
|
|
|
|
|
I suspect it is deleting the file, but you're immediately re-creating it after you've deleted it.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Tnx for reply.
Yes im creating the file after the deletion coz i to write new data into it. but the new data just appends to the old file. any suggestions?
|
|
|
|
|
Try changing the second parameter of the StreamWriter constructor (append ) to false .
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
SO SORRY EVERYONE! itz my bad. I checked the DialogResult as OK, while i have set the dialog to "YesNo" mode. It works.
Sorry again!
|
|
|
|