|
All I want the procedure to do is execute the sql statement that I pass it. I do not want or need any result to be passed back as the stored procedures will update or or insert to the tables.
private void SQLExecution(string WhatismyConnectionString, string MySQLStatement)
{
//This is the command I am passing in the SQL Statement...
//It is a stored procedure that simply does a deletion to the table.
//WhatismyConnectionString = "sp_vc_NoLongerExist + @MachineName + @UserName + @AppName"
SqlConnection conn = new SqlConnection(WhatismyConnectionString);
SqlCommand command = conn.CreateCommand();
command.CommandText = MySQLStatement;
command.CommandType = CommandType.Text;
// execute the command that returns a SqlDataReader
object returnvalue = command.ExecuteScalar();
MessageBox.Show("YEA?");
}
|
|
|
|
|
Hi JollyMansArt,
Please open the connection before using it.
Also,close the connection after you finish with it.
himanshu
|
|
|
|
|
Open your connection
Commandtype should be command.StoredProcedure
Create parameter object and then define all your parameter and then add your parameter in command object as
command.Parametyer.Add(put your parameter object here)
And execute as ExecuteNonQuery command.ExecuteNonQuery
Thanks,
Atin
|
|
|
|
|
Open the connection
Niladri Biswas
|
|
|
|
|
Dear All,
I have following xml which i want to convert it into DataTable, but it doesent reports any record
the xml file contents
<DownloadedForms>
<row>
<CommunityCode>28-2801-0001</CommunityCode>
<FormName>Form6</FormName>
<FormPage>1</FormPage>
<FormPath>c:\PDF Files\BAMYAN\Bamyan\28-2801-0001\Form6\28-2801-0001-F6.pdf</FormPath>
<isVerified>2</isVerified>
<RejectionReason>The Form is Scanned in low Quality</RejectionReason>
<Id>6</Id>
<ProvinceID>28</ProvinceID>
</row>
</DownloadedForms>
and the code to read the xml file is
XmlTextReader read=new XmlTextReader("xmltopic.xml");
while (read.Read()) {
}
DataTable dt=new DataTable();
dt.ReadXml(read);
MessageBox.Show(dt.Rows.Count.ToString());
how can i convert that xml into dataTable?
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
Try
DataSet ds = new DataSet();
ds.ReadXml("FileName");
himanshu
|
|
|
|
|
Yes its working!!
go ahead with Himanshu code

|
|
|
|
|
|
do some googling
you will get it
|
|
|
|
|
Please, don't delete your messages. It's not helpful to other people who are searching for an answer to a related question
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
I am really sorry, In fact i was trying to response for "himunshu1256", but i dont know y the respone was automoated to "savetiger".
I had responed to "himunshu1256" two times, but in both the message was redirected to "savetigers"
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
Creating DataTable from XML DataTable
DataTable mytab = new DataTable();
mytab.ReadXml("c:\\myfile.xml");
To Read your XML file U have read it to a Dataset.
like
Dataset myds = new Dataset ();
myds.ReadXml("c:\\tt.xml");
Get your table from
myds.Tables[0].Rows.Count
Rajesh B --> A Poor Workman Blames His Tools <--
|
|
|
|
|
I wrote a program to download .jar file to mobile ,but its is saving as .aspx file to mobile and it is reporting an error like this file is not supported by the device.But there is no problem with windows mobiles..
Please Help me to find out the solution for this.
Code Snippet I used to download as follows
protected void Command1_Click(object sender, EventArgs e)
{
string EXEPath = System.Configuration.ConfigurationManager.AppSettings["downloadEXEPath"].ToString();
string exefilename = System.Configuration.ConfigurationManager.AppSettings["EXEFileName"].ToString();
HttpRequest httpreq = Context.Request;
HttpResponse httpres = Context.Response;
FileInfo fil = new FileInfo(Server.MapPath("~\\" + EXEPath));
if (fil.Exists == true)
{
httpres.Clear();
httpres.ContentType = "application/java-archive jar";
httpres.AddHeader("Content-Length", fil.Length.ToString());
httpres.AddHeader("content-disposition", "attachment; filename=" + exefilename);
httpres.BinaryWrite(File.ReadAllBytes(Server.MapPath("~\\" + EXEPath)));
httpres.Flush();
httpres.End();
}
}
|
|
|
|
|
hi again , is there any way to dock a windows forum to the bottom right hand corner ?
Above the taskbar and to the right hand side of the screen ?
Thanks
modified on Wednesday, June 24, 2009 9:51 PM
|
|
|
|
|
Do you mean a form ?
There is nothing built in to do this, but you can write code to find out the size of the main screen, position it where you want, and handle the event when the form is moved, and move it back.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
this may give you some ideas[^]
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I have a WinForm with a DropDownList and DataGridView. I need to display the States based on the Country selected.
This is my Code:
private void cbCountry_SelectedIndexChanged(object sender, EventArgs e)
{
if (loading == false)
{
CountryId = (int.Parse(cbCountry.SelectedValue.ToString()));
this.dsWBGT = dataComm.GetStateByCountryId(CountryId);
dgvState.DataSource = this.dsWBGT;
}
}
When I step through the app everything works and the dataset gets the correct info but the DataGridView only display (Collection)
Can someone tell me what am I doing wrong?
I am populating the combobox with the following code:
private void PopulateCountries()
{
DataSet dsCountries = dataComm.GetCountries();
cbCountry.DataSource = dsCountries.Tables["Country"].DefaultView;
cbCountry.DisplayMember = "Country";
cbCountry.ValueMember = "Id";
}
Illegal Operation
|
|
|
|
|
Nevermind I found the problem...
Illegal Operation
|
|
|
|
|
|
Instead of referencing the datagridview (dgvState.DataSource = this.DataSet) I used the bindingsource (bindingSource.DataSource = this.DataSet).
Illegal Operation
|
|
|
|
|
In JavaScript you can run document.getElementsByTagName ("img") to get all of the image tags. Can you do something similar in C#?
Also you can do this is JavaScript:
var image = document.createElement ("img");
image.getAttribute ("src");
Again can you do something similar in C#? And if so, how?
This is how I'm getting the webpage: http://www.tech-recipes.com/rx/1954/get_web_page_contents_in_code_with_csharp/[^]
Thanks.
|
|
|
|
|
If it's really XHTML and not just plain old HTML, you could just treat it as xml: use XmlDocument and its SelectNodes(string xpath) function
At least, that's what I would do..
The xpath would be something like "//img/@src" I think (if you want all src attributes of all img's as your code seems to do)
|
|
|
|
|
Okay I'll give that a try.
I've found out that the XHTML isn't completely valid. Some of the tags aren't closed properly. Here's in excerpt:
<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">
<meta name="robots" content="noarchive"/>
<meta name="description" content="/a/ is 4chan's imageboard dedicated to the discussion of Japanese anime and manga."/>
<meta name="keywords" content="imageboard,japan,anime,manga"/><link rel="alternate stylesheet" type="text/css" href="http://zip.4chan.org/yotsuba.9.css" title="Yotsuba"><link rel="stylesheet" type="text/css" href="http://zip.4chan.org/yotsublue.9.css" title="Yotsuba B"><link rel="alternate stylesheet" type="text/css" href="http://zip.4chan.org/futaba.9.css" title="Futaba"><link rel="alternate stylesheet" type="text/css" href="http://zip.4chan.org/burichan.9.css" title="Burichan"><link rel="alternate" title="RSS feed" href="/a/index.rss" type="application/rss+xml" /><title>/a/ - Animu & Mango</title>
While some of the tags are somewhat formed properly, some aren't. The first one is easy:
result.Replace ("\"/>", "\" />");
I think I could use regex for the tags missing a closing "/" but I don't know how to do that.
[Edit]
Okay the result.Replace bit isn't working.
modified on Thursday, June 25, 2009 1:18 PM
|
|
|
|
|
I'm afraid you may have to use a custom parser, for HTML.. That will work, but it's a lot of work to make.
|
|
|
|
|
Well all of the HTML seems to be properly nested as per the XHTML specs, but some of the tags simply aren't closed properly. All I may need to do is C#'s version of PHP's preg_replace function.
|
|
|
|