|
Hi I am new to c# and .net, I am trying to add a data Connection as per the MS website http://msdn2.microsoft.com/en-us/library/3d1wkhas.aspx
The problem is that once the data connection is setup in the server explorer window I cannot drag this on to the form.
Hope you can help thanks
|
|
|
|
|
How would I go about capturing the user's desktop surface to use a Graphics object to draw on it? Thanks for the help in advance.
John 3:16: "For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life."
using Earth.Internet.WWW.CodeProject;
|
|
|
|
|
|
Depending on your requirement, you have two options.
Option 1 - Platform Invoke Win32 to obtain the desktop window.
1) Platform invoke a few Win32 calls from User32.dll, such as GetWindowDC() and GetDesktopWindow().
2) Construct a graphics object based on the desktop window resource you obtained.
3) Use the constructed graphics object to draw.
Option 2 - Use a transparent window to cover part or all of the desktop.
1) Create a transparent, no-border windows form.
2) Draw to that form.
Best,
Jun
|
|
|
|
|
Due to the fact that I want to maintain cross platform capability (in this case with Mono on platforms such as Linux and Mac OS), I think Option 2 is the better choice.
Thanks.
John 3:16: "For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life."
using Earth.Internet.WWW.CodeProject;
|
|
|
|
|
i have error in this method
DataSet DSCurrentCourse = new DataSet("tblCourse");
OleDbConnection con = new OleDbConnection(Form1.conString);
OleDbCommand cmd;
OleDbDataAdapter Adapter;
<br />
private void fillListCourse(int plane,int Snumber)<br />
{<br />
<br />
try<br />
{<br />
string sql = " SELECT tblCourse.CO_name, tblCourse.CO_number " +<br />
" FROM tblCourse INNER JOIN (tblSemesterPlane INNER JOIN tblSemsterCourse ON tblSemesterPlane.SMP_id = tblSemsterCourse.SC_SMP_id) ON tblCourse.CO_id = tblSemsterCourse.SC_CO_id " +<br />
" WHERE (((tblSemesterPlane.SMP_PL_id)=" + plane + ") AND ((tblSemesterPlane.SMP_number)=" + Snumber + "));";<br />
<br />
cmd = new OleDbCommand(sql, con);<br />
con.Open();<br />
<br />
}<br />
catch (Exception ex)<br />
{<br />
Console.Write("\n\n<<<--ERROR-->>>"+ex.StackTrace+"\n\n\n");<br />
}<br />
<br />
Adapter = new OleDbDataAdapter(cmd);<br />
DSCurrentCourse.Clear();<br />
Adapter.Fill(DSCurrentCourse, "tblCourse");<br />
con.Close();<br />
<br />
<br />
<br />
<br />
}<br />
the error in line Adapter.Fill(DSCurrentCourse, "tblCourse");
Palestine
|
|
|
|
|
|
Hi everyone
I am trying to automatically select a button on a form that I have navigated to via the webbrowser2 component in my C Sharp application. When I look at the data in the HTML source
the button that says submit looks like this.
Now I want to automatically call the submit function from the webbrowser component. I thought of the Post Data function which allows you to post data to an HTTP server. However, what do I post to the server, or is this an incorrect approach? Is there an easier way to automatically submit this form?
Thanks for your help
Dave
|
|
|
|
|
Dave,
While you are looking at this webpage, right-click and "view source".
Look for code between and that surrounds the search box and "go" button. This is a good demonstration of how form elements can be submitted to a server.
modified 1-Aug-19 21:02pm.
|
|
|
|
|
Thansk Richard, I posted in a follow up to Mike what I am currently doing. Perhaps I am mistaken as to why this button should not appear as an element of the Document. The only difference that I can see is that in the source, the "Cancel" button is of type "button" and the "Submit" button is of type "submit". I assume the "submit" is a Java Script function that gets called.
I am a bit new at the HTML side of things, but I am gradually getting it.
Thanks again
Dave
test
|
|
|
|
|
Dave_Roach wrote: via the webbrowser2 component in my C Sharp application.
Using the WebBrowser control you can access the DHTML interface for the browser then obtain the button "element" using DHTML call then call the button objects click() method.
Basically you are using DHTML from C# in the same way you would write Javascript for the browser.
You will find examples of using the WebBrowser controls DHTML interface on MSDN online.
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
Thanks for your reply, I appreciate any help I can get
I have a function in the code that I have been using to automatically select buttons. It looks lile this.
public bool ClickButtonOnDocument(HTMLDocument myDoc,string buttonLabel)
{
HTMLInputElement btnSearch ;
btnSearch = (HTMLInputElement) myDoc.all.item(buttonLabel, 0);
if(btnSearch == null)
return false;
else
{
btnSearch.click();
return true;
}
}
The button in question is not really a "button" in the source code, it is labelled "submit".
There is a "button" called "Cancel" that I can call with the above method. However, the "submit" button does not seem to be available in myDoc.all.item. So, I am at a bit of a loss. I assumed it should be available but since it's not labelled "button" perhaps it's not being found.
I am a little confused as to why it would not appear as an element.
Scratching my head... Dave
|
|
|
|
|
Dave_Roach wrote: public bool ClickButtonOnDocument(HTMLDocument myDoc,string buttonLabel)
Dave_Roach wrote: btnSearch = (HTMLInputElement) myDoc.all.item(buttonLabel, 0);
Your code seems to indicate that you are using the text "buttonLabel" to find the element object in the document.all collection. Have you read the documentation[^] ? It does not say to use the button text to retrieve the button element. document.all.item( vIndex) where vIndex is either a zero based "index" into the collection or if a "string" it is the "name" or "id" property of the element.
So if the submit button does not have a name or id property then you will not find it in the colleciton unless you know the zero based index of it which is very unlikely.
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
I am trying to work with the spliter class for my resize controls and i can not get how it works.
Can you help me and explain what it does and how it does it?
In my project i have 6 controlls that are in the form, i do not use panel,should I?
The form is very simple:
It has mainmanu and then toolbar and then in each corner of the form there is a controll, i mean
it looks like this:
mainmanu
toolbar
treeview lisbox
treevew listbox
How can i resize it all with the Spliter?
Thanks for you help[
|
|
|
|
|
You should use panels to do this. You must have at least two panels on your form. If you use VS 2005 than you can simply use SplitContainer control. If not then:
1. Add panel1 to the form and set panel1.Dock = Top.
2. Add splitter1 to the form and set splitter1.Dock = Top.
3. Add panel2 to the form and set panel2.Dock = Fill.
4. Add treeview1 to the panel1 and set treeview1.Dock = Left.
5. Add splitter2 to the panel1 and set splitter2.Dock = Left.
6. Add listbox1 to the panel1 and set listbox1.Dock = Fill.
7. Do steps 4-6 for the panel2.
|
|
|
|
|
Problem:
I want to insert into article table a new article. later insert articleid (Autoincrement) and category selected from checkboxlist (can be more than one category) into another table articlecategory.
Now i used a 'for' loop to iterate to insert into table articlecategory.\
now the problem is the table article is getting inserted twice with the first insert.
PLease enlighten me.
the code in C#:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
namespace cmside
{
///
/// Summary description for article.
///
public class article : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button btnarticlesubmit;
protected System.Web.UI.WebControls.TextBox txtarticlename;
protected System.Web.UI.WebControls.TextBox txtarticletext;
protected System.Web.UI.WebControls.TextBox txtkeywords;
protected System.Web.UI.WebControls.TextBox txtsummary;
protected System.Web.UI.WebControls.CheckBoxList categorybox;
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack==true)
{
SqlDataReader dr1;
SqlConnection con = new SqlConnection("Persist Security Info=False;User ID=sa;Initial Catalog=CMS");
SqlCommand cmd = new SqlCommand("select categoryID,categoryName from tblcategory",con);
con.Open();
dr1 = cmd.ExecuteReader();
this.categorybox.DataSource=dr1;
this.categorybox.DataTextField="categoryName";
this.categorybox.DataValueField="categoryID";
this.categorybox.DataBind();
dr1.Close();
con.Close();
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.btnarticlesubmit.Click += new System.EventHandler(this.btnarticlesubmit_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void btnarticlesubmit_Click(object sender, System.EventArgs e)
{
SqlConnection cn=new SqlConnection("Persist Security Info=False;User ID=sa;Initial Catalog=CMS");
SqlCommand cm=new SqlCommand("insert into tblarticle(articlename,athrid,articletext,articlekeywords,articlesummary) values('"+this.txtarticlename.Text+"','"+Request.QueryString["aid"]+"','"+this.txtarticletext.Text+"','"+this.txtkeywords.Text+"','"+this.txtsummary.Text+"');select @@identity as id;",cn);
cn.Open();
cm.ExecuteScalar();
cn.Close();
SqlDataAdapter da=new SqlDataAdapter(cm);
DataSet ds = new DataSet();
da.Fill(ds,"id");
int j = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
cn.Dispose();
cm.Dispose();
SqlConnection cn1=new SqlConnection("Persist Security Info=False;User ID=sa;Initial Catalog=CMS");
SqlCommand cmins= new SqlCommand("insertintoarticletocat",cn1);
cmins.CommandType=CommandType.StoredProcedure;
SqlParameter myparam = cmins.Parameters.Add("@categoryID",SqlDbType.Int);
SqlParameter myparam1 = cmins.Parameters.Add("@articleID",SqlDbType.Int);
for(int i = 0;i
|
|
|
|
|
Have you ever thought about creating a DAL (Data Abstraction Layer) to put all your database access in? It would make your code much tidier.
This is the offending code:
SqlConnection cn=new SqlConnection("Persist Security Info=False;User ID=sa;Initial Catalog=CMS");
SqlCommand cm=new SqlCommand("insert into tblarticle
(articlename,athrid,articletext,articlekeywords,articlesummary) values
('"+this.txtarticlename.Text+"','"+Request.QueryString["aid"]
+"','"+this.txtarticletext.Text+"','"+this.txtkeywords.Text+"','"+this.txtsummary.Text+"');select
@@identity as id;",cn);
cn.Open();
cm.ExecuteScalar();
cn.Close();
SqlDataAdapter da=new SqlDataAdapter(cm);
DataSet ds = new DataSet();
da.Fill(ds,"id");
First. It is suseptable to a SQL Injection Attack - You can find out what that is, how to recognise susceptable code and how to fix it here[^]
Second, the reason you are getting the row inserted twice is because you are asking it to get inserted twice.
This line inserts it the first time:
cm.ExecuteScalar(); And this line inserts it the second time:
da.Fill(ds,"id"); Why you are doing this I have no idea. It looks like you are trying to get the ID back out, but in doing so you are inserting the row twice.
The following should be sufficient:
int articleId = (int)cm.ExecuteScalar()
The remainder of the highlighted code after the cm.Close() can be removed.
Also, it looks like you are using a mix of styles, later in the code you are using a stored procedure. These conflicting styles will make code maintenance much more difficult in future. You should make a descicion to go all for stored srocedures (which is the option I recommend) or just don't use them at all.
Scottish Developers events:
* .NET debugging, tracing and instrumentation by Duncan Edwards Jones and Code Coverage in .NET by Craig Murphy
* Developer Day Scotland: are you interested in speaking or attending?
My: Website | Blog
-- modified at 11:36 Saturday 15th July, 2006
|
|
|
|
|
Hi,
i have two files one in .txt format and other in .xls format,
i have matching set of data in both the files, my requirement is to compare and
check the accuracy of the records whether both reflect the same set of data,
based on the comparision result the corresponding records needs to be flagged, in both the
files for each record compared. can any one guide me how to approach to acheive this.
Note: Files needs to be read/updated at one shot
Thanks in advance
Krishna
|
|
|
|
|
Krrish wrote: at one shot
What does that mean "specifically"? It is not a technical term.
Krrish wrote: based on the comparision result the corresponding records needs to be flagged, in both the
files for each record compared.
flaged how? based on what results? You should just post your homework assignment since you are not very good at paraphrasing it.
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
1)at one shot
*What does that mean "specifically"? It is not a technical term.
I mean the same function shoulad cater the requirement for both reading and updating the records
2)based on the comparision result the corresponding records needs to be flagged, in both the
files for each record compared.
*flaged how? based on what results? You should just post your homework assignment since you are not very good at paraphrasing it.
as i have mentioned i have 2 files containing matching records, i try to compare the accuracy of the set of records, when a record is matched i have a column "Matched" within the record, and i want to update that column based on comparision result,
ex: if a record in both files matches i update the column value as matched, otherwise as not-matched
in both the .txt and .xls files
Krishna
|
|
|
|
|
Krrish wrote: I mean the same function shoulad cater the requirement for both reading and updating the records
Ok well that is a really bad design but it's your project I guess.
Krrish wrote: i want to update that column based on comparision result,
If the character width of the column is not going to change then you can just set the "file position" and then overwrite the column data with the new bytes. If the data width is going to change then it is much more complex because you have to write the entire file from the first position that changes the data width.
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
is there any way that i can do sql operations to update the content,
am able to get the whole content by querying
string sqlstring = "SELECT * FROM temp.txt";<br />
string sConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\Shared\ExportAndDisplayData\;Extended Properties=Text;";<br />
OleDbConnection objConn = new OleDbConnection(sConnectionString); <br />
objConn.Open();<br />
OleDbCommand objCmdSelect = new OleDbCommand(sqlstring, objConn); <br />
objAdapter1.SelectCommand = objCmdSelect; <br />
DataSet objDataset1 = new DataSet();<br />
objAdapter1.Fill(objDataset1, "Test"); <br />
DataTable dt1 = objDataset1.Tables[0];
Thanks in advance
Krishna
|
|
|
|
|
call this function when delete record
function pagecount()
{
if(dgDocument.CurrentPageIndex >0)
{
dgDocument.CurrentPageIndex=dgDocument.CurrentPageIndex-1;
}
else
{
dgDocument.CurrentPageIndex=0;
}
}
vijay jain
|
|
|
|
|
|
What is your problem or question?
|
|
|
|