|
I have a project that I am working on that requires me to dynamically create the connection string to a SQL Server database. All of our SQL Servers are published within Active Directory. Within SQL Server there is a tab that allows you to add the instance of SQL to Active Directory. This can also be done for a database after SQL has been added to AD (the options tab at the bottom within SQL 2000).
With the database and the SQL instance published in AD I should be able to query AD to find the location of the database, i.e., What server is database X on?, I have looked through System.DirectoryServices and have been able to find how to do this. Any help/leads is greatly appreciated.
|
|
|
|
|
Hi again!
Well i got just the smallest of problems right now. I'm creating a sprite engine in C# and have ran into a problem when creating layers to my screen. The idea was to have a terrian layer, Object layer, and Control layer. Object layer being anything directly related to the game world and Controls being the GUI. The purpose of layers is so if only the controls changed i would only compute the change of the controls and just redraw what i had drawn previous with the past layers. Creating something of "Dirty Sprite" theory- ("Only redrawn what has changed - changed = dirty")
But the problem is before i was using these layers my program wiped the previous layer by filling it with white. I dont believe this will work anymore.
Is there a way to wipe a layer "clear"? So if i draw the layers on top of each other you'll be able to see the layers drawn first through the holes in the top most layers?
Thanks for your help in Advanced!
-- modified at 20:43 Thursday 1st December, 2005
|
|
|
|
|
I am having a lot of issues with this in VS2003 - programming in C#
I am trying to update one field in an XML file using a dataset
The code for the updating is
_______________________________________________________________
<br />
DataRow selectedRow = contacts.Tables[0].Rows[contactlist.SelectedIndex];<br />
selectedRow.BeginEdit();<br />
selectedRow["Service_Release_SQL"] =sr_sql.Text;<br />
selectedRow.EndEdit();<br />
contacts.WriteXml(@"contacts.xml");
______________________________________________________________
where "contactlist.SelectedIndex" gives me the XML row to update, and the field in that row is called "Service_Release_SQL"
This complies OK, and runs without throwing an exception but the result always is that my XML file loses all field after the "Service_Release_SQL"
field.
Can anyone indicate where I am going wrong
Thank you for your time
|
|
|
|
|
Should consult MSDN for this one, copied from there. You may be missing parts of this.
private void WriteXmlToFile(DataSet thisDataSet) {
// Create a file name to write to.
string filename = "myXmlDoc.xml";
// Create the FileStream to write with.
System.IO.FileStream myFileStream = new System.IO.FileStream
(filename, System.IO.FileMode.Create);
// Create an XmlTextWriter with the fileStream.
System.Xml.XmlTextWriter myXmlWriter =
new System.Xml.XmlTextWriter(myFileStream, System.Text.Encoding.Unicode);
// Write to the file with the WriteXml method.
thisDataSet.WriteXml(myXmlWriter);
myXmlWriter.Close();
}
|
|
|
|
|
Thanks
I suspect that my trouble is that the dataset is "set" to a different XML schema that the file being loaded (a previous version of the XML file), hence ignoring the columns after the ones it "knows about".
I suspect I will need to specifically load the schema, and save the schema as well as the data.
Will try it out on Monday when I get back to the office
|
|
|
|
|
I want to know how to control windows audio with C#
|
|
|
|
|
When your question is that broad, your best bet is google.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
This is my first time trying to work with a database. Let me explain what I've done real quick, then post my code, and you can tell me how I'm retarded. (Please)
First, I added an existing database to the project as a new data source. I did not have it automatically generate a typed dataset.
Next, in the design window, I added an untyped dataset to my form window. Then I placed a datagridview object in the window.
Under the DataGridView properties, I set the datasource to my untyped dataset.
I then modified my form code, as so:
<br />
public partial class PTAnalyzer : Form<br />
{<br />
public OleDbConnection conn;<br />
public OleDbDataAdapter dAdapter;<br />
public DataSet dSet;<br />
public string conString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\\..\\ptrack6.mdb";<br />
<br />
public PTAnalyzer()<br />
{<br />
InitializeComponent();<br />
<br />
try<br />
{<br />
conn = new OleDbConnection(conString);<br />
dAdapter = new OleDbDataAdapter("SELECT * FROM game WHERE player_id = 11", conn);<br />
dSet = new DataSet();<br />
dAdapter.Fill(dataSetPT, "game");<br />
}<br />
catch (Exception ex)<br />
{<br />
MessageBox.Show("Error : " + ex.Message);<br />
}
}<br />
}<br />
<br />
No errors, it runs fine. But nothing is displayed within the datagridview object. What am I doing wrong here? Thanks.
|
|
|
|
|
budidharma wrote: dSet = new DataSet();
//refreshes rows in the DataSet
dAdapter.Fill(dataSetPT, "game");
Did you mean dSet in that last line?
Jared Parsons
jaredp@beanseed.org
http://spaces.msn.com/members/jaredp/
|
|
|
|
|
Sorry, that dSet isn't actually used. I should delete that line. The data set is "dataSetPT."
|
|
|
|
|
|
Sure. I'm using VS 2005 rc3. The code was autogenerated by the IDE.
Here's the entire two files, most was autogenerated, excluding the stuff I posted in that first post.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace PTAnalyzer
{
public partial class PTAnalyzer : Form
{
// DATA ACCESS CODE
public OleDbConnection conn;
public OleDbDataAdapter dAdapter;
public DataSet dSet;
public string conString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\\..\\ptrack6.mdb";
public PTAnalyzer()
{
InitializeComponent();
// DATA ACCESS INITIALIZATION
try
{
conn = new OleDbConnection(conString);
dAdapter = new OleDbDataAdapter("SELECT * FROM game WHERE player_id = 11", conn);
dAdapter.Fill(dataSetPT, "game");
}
catch (Exception ex)
{
MessageBox.Show("Error : " + ex.Message);
} //try-catch
}
}
}
namespace PTAnalyzer
{
partial class PTAnalyzer
{
///
/// Required designer variable.
///
private System.ComponentModel.IContainer components = null;
///
/// Clean up any resources being used.
///
/// <param name="disposing" />true if managed resources should be disposed; otherwise, false.
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.dataSetPT = new System.Data.DataSet();
this.dataGridViewResults = new System.Windows.Forms.DataGridView();
((System.ComponentModel.ISupportInitialize)(this.dataSetPT)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dataGridViewResults)).BeginInit();
this.SuspendLayout();
//
// dataSetPT
//
this.dataSetPT.DataSetName = "PTDataSet";
//
// dataGridViewResults
//
this.dataGridViewResults.AutoGenerateColumns = false;
this.dataGridViewResults.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridViewResults.DataSource = this.dataSetPT;
this.dataGridViewResults.Location = new System.Drawing.Point(12, 47);
this.dataGridViewResults.Name = "dataGridViewResults";
this.dataGridViewResults.Size = new System.Drawing.Size(654, 325);
this.dataGridViewResults.TabIndex = 0;
//
// PTAnalyzer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(678, 384);
this.Controls.Add(this.dataGridViewResults);
this.Name = "PTAnalyzer";
this.Text = "PT Analyzer";
((System.ComponentModel.ISupportInitialize)(this.dataSetPT)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataGridViewResults)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Data.DataSet dataSetPT;
private System.Windows.Forms.DataGridView dataGridViewResults;
}
}
|
|
|
|
|
Specifically, in the second file, this is where the datagridview's datasource is set.
this.dataGridViewResults.DataSource = this.dataSetPT;
Really though, I'm trying to stumble through this and have no idea what I'm doing.
|
|
|
|
|
Finally just figured it out. I had to specifically set the datagridview datasource to a table index contained within the dataset. I was just setting it to the dataset.
|
|
|
|
|
Please can anyone tell me how to create Windows Services and deal with it(installing and running) coz it's not clear in the MSDN,
and there's another issue,
i want to make a Windows Service that let me control the Audio Volume of the Windows via short cut keys(like: Fn+UP or FN+DOWN),
how can i make it via C# and specialy in Windows Services....
thanks in advance.
|
|
|
|
|
|
Just a question, probably something easy...
I have a tab control setup with a user control in the tab. I want to have it so when a user makes their selection in the user control it will change tabs and load information in the new tab based on their selection... how would i reference the tab control from the user control? any thoughts? Thanks!
|
|
|
|
|
In my opinion, this is backwards. Your user control should be ignorant of its container, just like all of the other standard WinForm controls.
A better approach would be to have your user control raise an event when a selection was made. Your form would then catch that event and then change the tab selection.
|
|
|
|
|
Hmm, ok... do you know of anywhere with examples of how to do that?
|
|
|
|
|
|
Thanks in advance to those helping me. I'm somewhat of a novice, so possibly these questions are very trivial. I sure hope so!
I have a C# application that is generally instantiated by Internet Explorer / Mozilla, when a user downloads a filetype with my extension, then the application is called.
Unfortunately, the file downloaded by the browser is usually run from a temporary location, but this location depends on a number of factors, both by what type of browser. I need to process these files and save them for later, but unfortunately, since I don't know exactly where "here" is, I don't know where to look for them.
What I'd really like to do is figure out where my application is installed e.g., c:\Program Files\My Company\My Application\. But, since the user can type in any application during the install process, I can't just hard-code the path.
There has to be a place where that info is stored (My install application is a Visual Studio Deployment Project). Anyone know how to get to that?
If for some reason that's impossible, the next best option is to get the path to the current working directory.
|
|
|
|
|
|
private void loadRegimes()
{
XmlDocument document=new XmlDocument();
document.Load(xmlRegimes);
XmlNodeReader reader=new XmlNodeReader(document);
int standno=0,age=0,polygonno=0;
double acres=0;
ArrayList regimesList; //holding regimes for each stand
ArrayList regimeList; //hold ac cf wf data of regimes, ac cf wf data
ArrayList regimeObjList;//hold objetive value of each regime
int flowtype=0, flow=0, period=0;
string temStr;
while (reader.Read())
{
switch(reader.NodeType)
{
case XmlNodeType.Element:
switch(reader.LocalName)
{
case "stand": //cr
............................
Because the xmlRegimes is very large, the program get stucked, Is there a better way to load large xml file?
Thanks
|
|
|
|
|
There is.
The trouble with this approach is that you are loading the whole file into an XmlDocument, which keeps the whole thing in memory. You are then parsing this memory copy using a forward only reader.
Where possible, its better to stream the Xml in using XmlTextReader, this also is a forward only reader, but by using this you only deal with a tiny chunk of the whole document at a time. This is much prefered server-side as if you have multiple threads in your server each loading large xml documents in you could end up with a stressed server. This solution is far more scalable.
Regards,
Rob Philpott.
|
|
|
|
|
I was wondering if someone could point me in the right direction for creating a web component to an existing site, where an administrator could send the user messages. This is similar to etrade.com 's alerts or ebay's user inbox.. thanks!
MRH
|
|
|
|