|
Hi all,
This is the code, where the problem occurs.
SqlDataAdapter da = new SqlDataAdapter("UPDATE CompanyInfo SET CompName='abc' where CompID='" + CompID.Text.Trim() + "'", con);
DataSet ds = new DataSet();
da.Fill(ds);
int gh = da.Update(ds, "CompanyInfo");
da.Update(ds, "CompanyInfo")- fires an exception ("Update unable to find TableMapping['CompanyInfo'] or DataTable 'CompanyInfo'.").
Please suggest the idea.
Thanks and Regards
modified on Saturday, January 31, 2009 3:23 AM
|
|
|
|
|
The first thing is that the constructor of SqlDataAdapter expects to receive a SELECT string, not an UPDATE string. Also when using SqlDataAdapter you don't concatenate values to the statement (actually you should never do this.
It seems that you've mixed SqlDataAdapter with SqlCommand. So:
- create a proper select sattement
- use that when constructing
- if you want that the update statement is generated automatically, make sure that the select command contains key column from your table. Also use SqlCommandBuilder to create the select command
- otherwise create a SqlCommand for UPDATE and place that in SqlDataAdapter.UpdateCommand
After those steps you can try to call the Update method of the SqlDataAdapter.
|
|
|
|
|
Your code is such that I could erase your database any time i wanted. Please tell me this is a student assignment and not paid work.
Your code is stupid. You fill a dataset and then pass it through the data adapter - why ? You just want to run this SQL, you need no dataset for that. Are you making it up as you go along, or do you actually know somethign about C# or programming in general ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
|
when i try to write the events with the help of enterprise logging i am seeing them in Event viewer under Application. Is it possible to write events using enterprise logging in custom event logs (i.e other than Application any custom name like my project name). Please help me on this problem.
Md.Karimulla
|
|
|
|
|
|
Hi,
I am using datagridview for displaying the records from the database. Now I am fetching the records with the help of condition.
e.g. There are 1,2,3 records in my db.
if first condition satisfied I am calling display function where I passed the ID and with the help of that ID I am displaying the records.
Now the Problem is I want to update the datagridview so that all the records will display with the satisfied condition. Right Now I am getting the last satisfied record.
Thanks
|
|
|
|
|
just clear the datagridview before calling another condition
|
|
|
|
|
using System;
public class TokenizeDemo
{
public static void Main()
{
int tokenIndex = 0;
string values = "#55;xx sterrr,yy city,india";
string[] sites = values.Split(',', '#', ';', ' ', '/', '\0', '&', '-');
foreach (string a in sites)
{
// Console.WriteLine(a);
Console.WriteLine("token number is\t{0} token'd string is\t{1}\tlength of the string is {2}", tokenIndex++, a, a.Length);
}
}
}
output shows first token is null... how to rectify it... only strings should be tokenized..pls help friends
the quieter u become more u hear
|
|
|
|
|
lawrenceinba wrote: "#55;xx
The first token is null because of the # as the first character.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
|
|
|
|
|
Did you try reading the documentation ?
StringSplitOptions.RemoveEmptyEntries is what you need, it's a parameter on some overloads.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
then how can i bring 55 as token 0 and so on
the quieter u become more u hear
|
|
|
|
|
Exactly the way I said. I just tested it, and it works, if you use an overload that takes that parameter, 55 is index 0. Did you bother to try it ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
pls be clear i cant understand....
wat should i do to get token zero for 55
the quieter u become more u hear
|
|
|
|
|
bloody hell. Buy a C# book. Read my article on how to use google. If you can't understand my answer so far, then giving you the precise code will only move you further along the line of having people you work for think you have some sort of clue. And, if you're teaching yourself, refer to point a. Buy a book, and learn to use google, so you don't ask questions that are trivial, and so you know enough to be able to apply the answers when they are given to you.
I give up.
string values = "#55;xx sterrr,yy city,india";
char[] seperators = { ',', '#', ';', ' ', '/', '\0', '&', '-' };
string[] sites = values.Split(seperators, StringSplitOptions.RemoveEmptyEntries );
foreach (string a in sites)
{
// Console.WriteLine(a);
Console.WriteLine("token number is\t{0} token'd string is\t{1}\tlength of the string is {2}", tokenIndex++, a, a.Length);
}
But, you're pretty damn stupid to not be able to work that out from what I told you, which included a description, and all the keywords you need to find a working example with google, in seconds. I confirmed this when I responded to you.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
im so sorry.... im a minor kid... just writting codes for school work..
again sorry for making u angry
the quieter u become more u hear
|
|
|
|
|
Maybe you should buy a game console and give up on coding...
"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
|
|
|
|
|
hi....
it bcz the first spliting occured by #..
here left string to # is NULL...
|
|
|
|
|
hai all,
i want to create encrypted xml in server machine through windows application ,how can i create this .
thanks& regards
vishnu
|
|
|
|
|
Check out the cryptography namespace.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
|
AoA
I was working on a project. I want to discuss a question, is it possible that we override whole definition of existing class.
Means e.g. I make my own class named TextBox. And it override the existing windows class. Whenever TextBox is written it supposed to be my class. We dont have to provide a whole path means. namespace.className.
Please help me out if any one can. Thanks in advance.
|
|
|
|
|
No, you can't do that, you can't make the entire project just magically use a class other than the one you actually used. The best you can do is a search and replace.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
yes i understand your suggestion. My requirement is i want to paint all controls by myself. I searched the net and find a way that can be possible is Hooks. But i can not find exact Paint Messages of each control. Can you help me in it. and Thanks for your reply of previous question.
|
|
|
|
|
Hooks do not do what you hope to do. The most likely thing is a using statement at the top of every class which redefines the TextBox, for example, as being an object called TextBox in your namespace instead of the usual one.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|