|
Hi,
I have an xml file with employee data and need to uplaod its content to the database.
For this I have used dataset.ReadXml method and then I am using the dataadapter.update method to upload the content of the dataset to the database.
Here is the code:
protected void Button1_Click(object sender, EventArgs e)
{
string path = @"D\emp.xml";
string dsTable = "";
string connectionString = @"Server = DB\SQL2; Database = CWBDB; user = sa; password = sa";
DataSet ds = new DataSet("EMPDS");
ds.ReadXml(path);
foreach (DataTable t in ds.Tables)
{
dsTable = t.ToString();
}
SqlConnection con = new SqlConnection(connectionString);
SqlDataAdapter da = new SqlDataAdapter();
da.TableMappings.Add("EMP", dsTable);
if ((da.Update(ds))>0)
{
Label1.Text = "Uploaded the data successfully";
}
else
{
Label1.Text = "Could not Upload the data";
}
}
But I see an exception:
"Update unable to find TableMapping['Table'] or DataTable 'Table'."
Please help!
-- modified at 8:15 Wednesday 11th April, 2007
Rakesh
|
|
|
|
|
rockyl wrote: foreach (DataTable t in ds.Tables)
{
dsTable = t.ToString();
}
What are you trying do here ? i think it will overwrite in each loop
Thanks and Regards
Sandeep
If you want something you never had,
do something you have never done!
|
|
|
|
|
da.TableMappings.Add("EMP", dsTable);
The above statement of my code makes a mapping between database table and dataset table, the first parameter is the database table name and the 2nd paramaeter is dataset table name. So I am getting the table name from the dataset and passing to it so that a mapping may occur between the database table and the dataset table.
In short I will explain what I am trying to do. Theres an xml file consisting of Employee data, I need to upload this xml content to the Database. For this I have used the Dataset.fill(xmlpath) and then using the dataadapter for updating the data to the database. Now u can see my previous code and get clear understanding.
Rakesh
|
|
|
|
|
how do i upload a image in thumbnail format
monu_khan
|
|
|
|
|
Why you want the imgae in the thumnail format ?
Thanks and Regards
Sandeep
If you want something you never had,
do something you have never done!
|
|
|
|
|
|
Hi All,
What is meant by pearreview and codereview?
Explain me with example
Thanks.
|
|
|
|
|
Hi,
PeerReview is review done by your peers (co-workers)to identify bad code which leads to malfunctioning of the application.
CodeReview is also the same thing but can be done by anyone not only your peers.
Rakesh
|
|
|
|
|
hi
In want to develop a project" leave management system "in ASP.NET
in that how to transfer details we type in web forms to outlook??
whatever i save in web form will get updated in database which is saved in server, so how to get the datas from text box to outlook content.
i inherited the component microsoft outlook view, but i dont know how to use it.in what format it will be saved in outlook express.
tanksss
shalini
shs
|
|
|
|
|
Hi all,
i just want to know that if i install .NET framework before IIS what is the command that i can use so that i don`t need to reinstall both again.
This is because you can`t execute the project if you do so. You have to do vice versa. can any buddy gimme the command or an exe file that should be executed to solve the prob.
thanks in adv...
|
|
|
|
|
Hi,
See Link
OR
You can reinstall just the framework.
Mubashir
Software Architect
Storan Technologies Inc, USA
Every job is a self portrait of the person who did it.
|
|
|
|
|
Use this tool aspnet_regiis.exe located in Microsoft.NET\Framework\vxxxxxx
<< >>
|
|
|
|
|
simply run %windir%\Microsoft.NET\Framework\version\aspnet_regiis.exe -i
at command prompt version will be the version of .net u are using
monu_khan
|
|
|
|
|
Hello,
VS 2005
I have created a web service and the web service as a connection string in the config file.
Only the user will know the connection string details when they first install the web service. i.e. server, user id, database etc.
I have created the setup using the msi webSetup.
However, my problem is how do i get the user information for the connection string from the user and update the web.config with the new connection details.
Need serious help with this, and code examples would be most helpful.
Thanks very much,
Steve
|
|
|
|
|
Hi,
I am trying to create a web control that contains a hyperlink and an image and make it possible to set some properties.And I want to show a popup when the mouse is over one of them.From what i understand a solution would be to include the image in the hyperlink and write the code for the necessary events only for the hyperlink.But when I include the image in the hyperlink, and a literal to I no longer see the image.Do you think you can help me with that?
Thanks
Here is how I try to include the image:
hyperlink.Controls.Add(image);<br />
hyperlink.Controls.Add(literal);<br />
this.Controls.Add(hyperlink);
I want the page source to look something like this
<br />
a href="http://www.zzz.com" style="font-size:10px"><br />
<img src="http://www.zzz.com/295384c2bbdd7a96e5432be08b42036e.gif" width="50" height="50" <br />
zzz<br />
/a<br />
-- modified at 6:17 Wednesday 11th April, 2007
|
|
|
|
|
Why not use a linkbutton
something like
<br />
asp:LinkButton id="lbtnJumptToZZZ" runat="server"><br />
<img border="0" src="http://www.zzz.com/295384c2bbdd7a96e5432be08b42036e.gif" alt="ZZZ"><br />
asp:LinkButton<br />
the click event should then contain the redirect to the page or opening it
in a new window.
//To open in a new window:
<br />
private void lbtnJumptToZZZ_Click(object sender, System.EventArgs e)<br />
{<br />
string webRef = "http://www.zzz.com";<br />
<br />
script = "<Script Language=\"JavaScript\"> " + <br />
" window.open " +<br />
" ('" + webRef + "','','scrollbars=yes,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no'); " + <br />
"</Script>";<br />
<br />
Page.RegisterStartupScript("script", script); <br />
}<br />
-- modified at 8:11 Wednesday 11th April, 2007
|
|
|
|
|
That's not what i want .I want to know how to include ,using c#, an image in a hyperlink(linkbutton() so that when i click on the image or on the text redirects me.
|
|
|
|
|
If you want to this at the code behind:
<br />
LinkButton lbtn = new LinkButton();<br />
lbtn.Click += new System.EventHandler(this.lbtn_Click);<br />
<br />
lbtn.Text = "The text to display " + "<img border=\"0\" src=\"http://www.zzz.com/295384c2bbdd7a96e5432be08b42036e.gif\" alt=\"ZZZ\">";<br />
<br />
this.Controls.Add(lbtn);<br />
<br />
<br />
private void lbtn_Click(object sender, System.EventArgs e)<br />
{<br />
Page.Redirct("http://www.zzz.com/"); <br />
}<br />
It's not easy to make the text and the image align the way one wants, so
often I splitt it in to 2 linkbuttons. One for the name and one for the image.
|
|
|
|
|
i have a column in datagrid that expose the company name....when the name of the company is long it is divided into multiple lines ...i want to force these lines to be one line and the remaining of the name is hide when the mouse over it, the remaining of the name appear
haitham
|
|
|
|
|
Hers a custom control you can use:
<br />
using System;<br />
using System.Web.UI.WebControls;<br />
<br />
namespace My.Controls{<br />
<br />
public class TruncLabel :Label {<br />
public TruncLabel() : base (){}<br />
<br />
protected override void Render(System.Web.UI.HtmlTextWriter writer){<br />
this.CssClass="fxS";<br />
this.ToolTip = this.Text;<br />
base.Render(writer);<br />
}<br />
}<br />
}<br />
Your stylesheet should then contain the following:
<br />
.fxS<br />
{<br />
overflow:hidden;<br />
white-space:nowrap;<br />
overflow-clip:rect(auto, auto, auto, auto);<br />
}<br />
The page containing the datagrid
<br />
<%@ Register TagPrefix="mi" Namespace="My.Controls" Assembly="MyProjectOrSomething" %><br />
.<br />
.<br />
asp:datagrid id="myDataGrid" runat="server" CssClass="grid" GridLines="None" AutoGenerateColumns="False"><br />
Columns><br />
asp:TemplateColumn HeaderText="Name" ItemStyle-VerticalAlign="Top"><br />
ItemTemplate><br />
mi:TruncLabel id="tlblName" Font-Bold="True" runat="server"><br />
<%#DataBinder.Eval(Container.DataItem, "strCompanyName").ToString()%><br />
mi:TruncLabel><br />
ItemTemplate><br />
asp:TemplateColumn><br />
Columns><br />
|
|
|
|
|
thanks for your reply
but can`t we use the ordinary label and change cssclass and tooltip properties of this label?..
i will try it and tell u
thanks again for your help....
haitham
|
|
|
|
|
Hello EveryBody,
I want to populate the dropdownlist from database,
but i am not able to set the categoryId as value
and categoryName as text in dropdownlist box.
Regards,
rahul saini
|
|
|
|
|
What problem when binding? Show your snippet of code???
<< >>
|
|
|
|
|
Hello
Thanks for your reply.
I am using following code:
string selectQuery = "SELECT * FROM Category ";
SqlConnection myConn = new SqlConnection(Application["Conn"].ToString());
SqlDataAdapter myAdapter = new SqlDataAdapter(selectQuery, myConn);
DataSet myDataset = new DataSet();
myAdapter.Fill(myDataset);
foreach (DataRow memberRow in myDataset.Tables[0].Rows)
{
ddlstCategoryList.Items.Add(memberRow["categoryName"].ToString());
}
I m getting the data but i want text as well as ite value.
regards
rahul saini
|
|
|
|
|
monuSaini wrote: foreach (DataRow memberRow in myDataset.Tables[0].Rows)
{
ddlstCategoryList.Items.Add(memberRow["categoryName"].ToString());
}
try to replace with this ddlstCategoryList.Items.Add(new ListItem("text","value");
you have to use another overrided method (with parameter is ListItem object)
<< >>
|
|
|
|