|
Hi,
No, you can't do this with the "List" View style. But you can set View = Details, add one column and set HeaderStyle = None if you don't want your users to see column header.
|
|
|
|
|
I can get the username, which will work most of the time, but as for example on my computer, the address is
C:\Documents and Settings\USER.OWNER-VS1SHD0MH8\My Documents\
because my computer is wierd.
But i need to know how to get to 'My Documents' every time.
|
|
|
|
|
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
Hope that helps
|
|
|
|
|
Oh yeah, thats good.
You learn somehting new every day. Its a miracle i didn't find this sooner, just think of the minutes i could have saved typing!!
|
|
|
|
|
i am building a software that will read from a csv file that is constantly been lock by an avaya smdr that keeps on writing to that file, but i want my program to be able to jus open the file and read it is this possible?? or once another program has lock a file for readAndWrite i cant even read from that file
kenny
|
|
|
|
|
|
thanks for the link i jus getting ready to leave the office but as soon as i reach home i going read it.
kenny
|
|
|
|
|
i reading through the example u sent me and i saw how it would allow you to read write to a integer value name resource but how would i use this in terms of reading from a text file
kenny
|
|
|
|
|
i am using this code to print a report but the problem comes when i pass parameters like Supplier_Id as i have done in this query the error comes like "Query engine Error and follows with the path.I am using this code.Well the problem doesn't comes with the query in which i have not passed parameters Pls help me to sort out this problem.Thanks Fahad.
try
{
int Supplier_Id=Convert.ToInt32(Supplier_Id_C.Text);
string s_p="sp_P_S_Rpt";
SqlConnection conn = Class_Connection.Make_Conn();
// SqlCommand command = new SqlCommand(s_p, conn);
// command.CommandType = CommandType.StoredProcedure;
// command.Parameters.Add("@Supplier_Id", SqlDbType.Int);
// command.Parameters["@Supplier_Id"].Value = Supplier_Id;
// SqlDataAdapter adapter = new SqlDataAdapter(command);
// DataSet ds = new DataSet();
// adapter.Fill(ds, "P_S");
//
// dataGrid1.DataSource=ds;
// dataGrid1.DataMember="P_S";
// P_R_Rpt obj = new P_R_Rpt();
// obj.SetDatabaseLogon("sa","sa","CDMA","Final_Project1_e");
// obj.SetDataSource(ds);
// crystalReportViewer1.ReportSource=obj;
// Cursor = System.Windows.Forms.Cursors.Default;
//reportDocument1.SetDatabaseLogon("sa","sa","CDMA","Final_Project1_e");
// reportDocument1.SetDataSource(ds);
// crystalReportViewer1.ReportSource = reportDocument1;
// Finalized.P_R_Rpt obj = new P_R_Rpt();
// obj.SetDatabaseLogon("sa","sa","CDMA","Final_Project1_e");
// reportDocument1.SetDataSource(ds);
// crystalReportViewer1.ReportSource = reportDocument1;
SqlCommand command = new SqlCommand(s_p, conn);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@Supplier_Id", SqlDbType.Int);
command.Parameters["@Supplier_Id"].Value = Supplier_Id;
SqlDataAdapter adapter = new SqlDataAdapter("SELECT dbo.Supplier.Supplier_Name, dbo.P_Order.P_O_Date, dbo.P_Order.P_O_Serial_No, dbo.P_Order.P_O_Id FROM dbo.P_Order INNER JOIN dbo.P_O_Details ON dbo.P_Order.P_O_Id = dbo.P_O_Details.P_O_Id INNER JOIN dbo.Supplier ON dbo.P_O_Details.Supplier_Id = dbo.Supplier.Supplier_Id WHERE(dbo.P_O_Details.Supplier_Id = 2)","Data Source=CDMA;Database=Final_Project1_e;UID=sa;PASSWORD=sa");// = new SqlDataAdapter(command);
//P_R ds = new P_R();
//SqlDataAdapter adapter = new SqlDataAdapter(command);
DataSet ds = new DataSet();
adapter.Fill(ds,"P_R_Rpt1");
dataGrid1.DataSource=ds;
dataGrid1.DataMember = "P_R_Rpt1";
//P_R ds = new P_R();
// P_R_Rpt obj = new P_R_Rpt();
// obj.Load();
// obj.SetDataSource(ds);
P_R_Rpt1 obj = new P_R_Rpt1();
obj.SetDataSource(ds);
//obj.Load();
//sample_Rpt1.FilePath = @"C:\\Documents and Settings\\Fahad\\Desktop\\Finalized_With_Report\\Sample_Rpt.rpt";
obj.SetDatabaseLogon("sa","sa");//oRpt.SetDataSource (ds);
crystalReportViewer1.Visible=true;//CrystalReportViewer1.Visible=true;
crystalReportViewer1.DisplayGroupTree=false;
crystalReportViewer1.ReportSource = obj;//CrystalReportViewer1.ReportSource = oRpt;
//obj.Load();
//obj.Refresh();
// crystalReportViewer1.RefreshReport();//.RefreshReport()
// crystalReportViewer1.Refresh();//crystalReportViewer1.Refresh()
// crystalReportViewer1.Show();//crystalReportViewer1.Show()
}
catch(Exception ee)
{
MessageBox.Show(ee.Message);
}
|
|
|
|
|
Fahad Ali wrote as the subject line: Pls Help Me !!!
Just about every one here is looking for help. This is a useless subject line. You should use something more meaningful. For example "Query Engine Error" would be better.
|
|
|
|
|
how can write protection class for applications created in c# which work with a validation key or serial number etc ?
is there any way to do it crack proofed?
also i'd like my program be available for a specific "trial period" and be locked after this period. application shoul not be "unlocked" after Reinstalling.
thanks in advance.
knowledge is power (%)
|
|
|
|
|
persian_king wrote: is there any way to do it crack proofed
You come with that and Bill Gates will sing at your birthday party.
There are plenty of third party products that offer these types of features. You can always write your own, but of course it will only be as good as your code and testing process.
|
|
|
|
|
Hello,
I think this will helpfull to u.
regards,
Divyang Mithaiwala
System Engineer & Software Developer
|
|
|
|
|
Hello everyone,
This may seem like an odd question but here goes.
I'm using the PropertyGrid for a project of mine -- works great and I've used the EnumDescConverter and PropertySorter TypeConverters that I found on CodeProject.
Basically I have an (older) application (.NET 1.1) that I have moved to .NET 2.0. In the older application, I had a class with a Layers property that contained a collection of Layers. I used the ExpandableObjectConverter to let the PropertyGrid show a + sign beside the layers as well as a list of the layers. This was great. Basically it was something like
public class Config
{
...
private LayerCollection m_Layers = new LayerCollection();
[TypeConverter(typeof(ExpandableObjectConverter))]
public LayerCollection Layers
{
get { return m_Layers; }
}
...
}
LayerCollection implemented CollectionBase, as well as ICustomTypeDescriptor to show "Layer #" beside each entry. This worked great.
Now, however, I'm restructured things so that it looks something like this:
public class Config
{
...
private List<Layer> m_Layers = new List<Layer>();
public List<Layer> Layers
{
get { return m_Layers; }
}
...
}
If I apply the ExpandableObjectConverter to the Layers properties, it just shows the Count property of the List. Hmmm. Not what I wanted. I know I'm missing something here -- just not sure what.
I used the generic List because it was easy -- but now I'm thinking that I may have to go back and have a LayerCollection class again so that it can implement the ICustomTypeConverter. Maybe make that generic so I can reuse it, but still.
Any ideas? Has anyone else run into a similar fiasco?
Thanks!
-Matt
|
|
|
|
|
Nevermind
I created a class called ExpandableList<T> that inherits from List<T> AND implements ICustomTypeDescriptor.
This is a pretty useful technique, I'll post it as an article soon.
-Matt
Bart: Look at me, I'm a grad student. I'm 30 years old and I made $600 last year.
Marge: Bart, don't make fun of grad students. They've just made a terrible life choice.
-- modified at 22:27 Wednesday 12th July, 2006
|
|
|
|
|
I first tried this code that passes a couple of parameters (part number, part type number) to a stored procedure. I can get this to run fine, insert the data into the table, no problem.
However, I want the stored procedure to return a field that is an auto-increment field called ID.
The stored procedure is syntactically correct, so I'm inclined to think it's something with the C# code.
The error I'm getting is: Parameter1 is not a parameter for procedure UpdatePart_Step_1_Test3
This is the c# code (note that I have so additional parameters that I declare but am not yet passing):
private void btnAdd_Click(object sender, System.EventArgs e)<br />
{<br />
strPartNumberInputReference = txtSearchPart.Text;<br />
strPartTypeID = ddPartType.SelectedValue;<br />
strDwgNumber = txtDwgNumber.Text;<br />
strDwgRevision = txtDwgRevision.Text;<br />
strDwgLocation = txtDwgLocation.Text; <br />
SqlParameter param1 = new SqlParameter("@PartNumber", strPartNumberInputReference); <br />
param1.Direction = ParameterDirection.Input;<br />
SqlParameter param5 = new SqlParameter("@PartTypeValue", strPartTypeID);<br />
SqlParameter param6 = new SqlParameter(@ID, SqlDbType.Int);<br />
param6.Direction = ParameterDirection.Output;<br />
IDOutput = SqlHelper.ExecuteNonQuery (this.connectionString, CommandType.StoredProcedure, "dbo.UpdatePart_Step_1_Test3", param1, param5, param6);<br />
test3 = param6.Value;<br />
<br />
}
Here is the stored proc:
CREATE PROCEDURE [dbo].[UpdatePart_Step_1_Test3]<br />
@PartNumber varchar (15),<br />
@PartTypeValue varchar (60),<br />
@ID int OUTPUT<br />
<br />
AS<br />
<br />
if NOT EXISTS (Select * from PartsDB.dbo.Parts where PartNumber = @PartNumber)<br />
BEGIN<br />
<br />
insert into PartsDB.dbo.Parts<br />
(PartNumber, PartTypeID)<br />
<br />
VALUES<br />
(<br />
@PartNumber,<br />
@PartTypeValue<br />
)<br />
<br />
END<br />
SET @ID = @@IDENTITY<br />
<br />
return 0<br />
GO
Again, if I just send in param1 and param 5 (and change the stored proc so it's not expecting a third parameter) it works fine!
Any ideas what is causing the error? I'm not finding any documentation.
|
|
|
|
|
leckey wrote: SqlHelper.ExecuteNonQuery
This is obviously a helper class, what does the code look like ?
Your code knows far too much about your data layer, why have a helper method and pass it SQL Parameters ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I think the helper is from the Microsoft Application Block for DAL
"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'm not quite sure what you mean by the second part...
I also tried with a dataset (even though the sp is just an insert) and got the same error. If I don't try to return anything, it's fine.
The code in the helper class goes through quite a bit, so I'll try to paste it as the compiler goes through it.
Step 1:
public static int ExecuteNonQuery(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)<br />
{<br />
if( connectionString == null || connectionString.Length == 0 ) throw new ArgumentNullException( "connectionString" );<br />
<br />
using (SqlConnection connection = new SqlConnection(connectionString))<br />
{<br />
connection.Open();<br />
<br />
return ExecuteNonQuery(connection, commandType, commandText, commandParameters);<br />
}<br />
}
Step 2:
public static int ExecuteNonQuery(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)<br />
{ <br />
if( connection == null ) throw new ArgumentNullException( "connection" );<br />
<br />
SqlCommand cmd = new SqlCommand();<br />
bool mustCloseConnection = false;<br />
PrepareCommand(cmd, connection, (SqlTransaction)null, commandType, commandText, commandParameters, out mustCloseConnection ); RUNS THIS FINE <br />
int retval = cmd.ExecuteNonQuery(); GETS STUCK ON THIS<br />
<br />
cmd.Parameters.Clear();<br />
if( mustCloseConnection )<br />
connection.Close();<br />
return retval;<br />
}
If there is a quick and painless other way to do this I'm all ears...or eyes really. I just want to get done with this!
|
|
|
|
|
leckey wrote: I'm not quite sure what you mean by the second part...
Your presentation layer shouldn't do more than call the middle tier with the data that needs storing. The middle tier should pass the data to a database layer, and inside THAT you should write code that knows what stored proc is being called.
The big question is, why are you using this Microsoft thingy ? What is it giving you ? I've done code that calls a stored proc and gets the out param heaps of times, but I have no idea on how best to use this Microsoft layer that you've got in place, or why you'd use a layer when your overall approach is not n-tiered at all.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I haven't programmed in about 3 years and a programming friend recommended it to me.
Could you give me an example? The more specific the better...I'm not very bright.
|
|
|
|
|
An example of the call, or of proper n-tiered development ?
SqlCommand cmd = new SqlCommand("InsertTrack", Connection);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@artistName", (artist == null) ? "" : artist);
cmd.Parameters.Add("@trackName", (track == null) ? "" : track);
cmd.Parameters.Add("@albumName", (album == null) ? "" : album);
cmd.Parameters.Add("@filePath", filePath);
cmd.Parameters.Add("@isVideo", isVideo ? 1 : 0);
cmd.Parameters.Add("@thumbPath", (thumbPath == null) ? "" : thumbPath);
cmd.Parameters.Add("@trackID", -1);
cmd.Parameters["@trackID"].Direction = ParameterDirection.Output;
cmd.ExecuteNonQuery();
return (int) cmd.Parameters["@trackID"].Value;
That's a call out of the data layer of a video jukebox I wrote. It represents a complete static function in a class that has the Connection as a lazy initialised static member property.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Christian Graus wrote: cmd.Parameters.Add("@trackID", -1);
Why -1 versus SqDbType.Int?
I'll be trying your version of code in a minute...be wary..I'll probably have more questions.
|
|
|
|
|
That code is a little over complex, it's passing in some values based on booleans. However, the add method takes a name and a value, not a value type, from the look of it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|