|
hi, how can i save a real picture on the SQL DB and retrieve it through .net
Thanks alot
Hamody
|
|
|
|
|
I'm having a very odd problem. I have a basic C# form app that pInvokes into a C++ dll. When I build my C++ dll and C# app in Release mode, the C# app can load the dll and call into it just fine.
However if I build the solution in Debug mode, the C# app throws a DllNotFoundException. I've double checked and the C++ debug version of the dll is being properly copied into the C# app's bin/debug folder, so its actually there.
Why is it able to load the release version and not the debug version?
|
|
|
|
|
dxben wrote: I've double checked and the C++ debug version of the dll is being properly copied into the C# app's bin/debug folder, so its actually there.
And the name of the debug dll is the same?
xacc.ide-0.1 released! Download and screenshots
|
|
|
|
|
Yeah its the same. Actually someone else pointed out to me that my debug dll is probably dependent on the debug dll of the CRT and that it can't find it. So I need to make sure the debug DLL of CRT is in my path. What is the filename of the debug crt DLL?
|
|
|
|
|
i have an object
public class Class2 : System.MarshalByRefObject
{
public Class2 ( ) { } // default constructor
public Class2 (string param1, string param2) { }
}
i cant use the 2nd constructor with remoting, when i use wsdl on the remoting url it doesnt have a signature for the 2nd constructor.
how do i implement this?
thanks
|
|
|
|
|
I guess you want an object instantiated with the second constructor to be registered with the remoting framework. If that's what you wanted to do, use the Marshal[^] method. Like
Class2 c2 = new Class2("x", "y");
RemotingServices.Marshal(c2,...);
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
HI,
I have a usercontrol with a testbox in it, and i am using "keydown" event of the textbox with in the control (for my specific functionality) .( i am using this control in my (win)form).
On form level i have one "Button". and i set "AcceptButton" property of form to this button.
My problem is, when i hit enter key while having focus on textbox of usecontrol, "Acceptbutton" property of form is executing instead of "keydown" event of usercontrol.
How do i make execute, "keydown" event of usercontrol on hitting enter key?
Regards,
satz
|
|
|
|
|
You can't get it to do both. AcceptButton is used to indicate the button that is to get the notification when the user presses Enter in the dialog.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
I have a trivial question.
When we create a C# windows application "bin" and "obj" folder is created in the project folder.
Will anyone please tell me that what is the signifance of these 2 folders.
Thanks a lot
|
|
|
|
|
The obj directory is a temporary directory. Visual Studio uses this for temporary files when compiling and linking. Files out of the bin directory are what you should deploy. This is the directory to which build variables like $(TargetPath) refer.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thanks Heath
I got your point
|
|
|
|
|
The bin (binaries) folder is the one you should be using. The obj folder is used to hold temp build files and for debugging purposes.
The bin folder has seperate directories for your build types and generally you want to build .pdb files with your release build in case you have to do any remote debugging.
|
|
|
|
|
Hi.. I'm currently doing a web design on the calendar using C# web application.I have created a calendar. I would like to ask that if i click the date on the calendar, can i retrieve the database?? I have tried several times and it seem like is not working. Below is my code, could anyone help me that if i missing on any parts?? Thanks!! My code:
.
.
.
using System.Data.SqlClient
private void Calendar1_SelectionChanged(object sender, System.EventArgs e)
{
TBDate1.Text = CAL1.SelectedDate.ToLongDateString();
SqlConnection conn=new SqlConnection("put my connection string here");
string seldate = "Select * from Particulars where DateField = '" + TBDate1.Text + "'";
SqlDataAdapter DA = new SqlDataAdapter(seldate,sqlConnection1);
DataSet DS = new DataSet();
DA.Fill(DS);
DataTable DT = new DataTable();
DataGrid1.DataSource=DS.Tables[0].DefaultView;
DataGrid1.DataBind();
}
Thanks for your help..;)
Cheers!
|
|
|
|
|
First of all, never use string concatenation like that in SQL strings. All I have to do as an attacker is set the TBDate1.Text field (either in the page or via an HTTP GET or POST) to ' or 1=1; delete from Particulars; -- and your table is gone. With probing I could do worse, such as steal credit card information or other private information, etc. This is called a SQL injection attack and is one of the most overlooked vulnerabilities. Use parameterized queries using the SqlCommand.Parameters collection property.
That's also the answer to the problem here. Dates are typically surrounded by "#" (depending on the database management system) but using parameters eliminates having to know that:
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = "SELECT * FROM Particulars WHERE DateField = @Date";
cmd.Parameters.Add("@Date", SqlDbType.DateTime).Value = DateTime.Parse(TBDate1.Text);
Add some error-handling, though, since DateTime.Parse could fail if incorrectly formatted.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hello,
I've declared an instance of a class in the startup page of my app
eg Car mycar = new Car()
and have assigned various attributes into it.
I would like to refer to the instance mycar in other pages (either in the aspx or .cs )
eg mycar.model
I'm getting The type or namespace name 'mycar' could not be found (are you missing a using directive or an assembly reference?)
What's the best way to declare the instance of this class to my other pages?
thanks,
John
|
|
|
|
|
Pages are executed in separate threads, such that an instance of one page is not persistent so one page can't access the variable of another. Store singleton class instances in your Application object in global.asax or use a singleton. There's many ways to do this. You can find more suggestions in the ASP.NET forum.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
thanks for your reply Heath,
Each user will have their own instance, with different properties - I assume a singleton is not appropriate?.
The class is declared in its own namespace.
Initially I referred to the class directly (rather than its instance) in other pages via the using 'namespace' entry. This worked, but each user overwrote the properties of the class!, hence of course I needed to use the class instance!.
I was hoping to reference the class instance in a similar way.
I may need to store the class instance in session (from the initial page), then retrieve it when needed.
thanks,
John
John
|
|
|
|
|
You only defined the class. An instance is created for each page request (even the same page in a different request, like after a post-back). This is crucial to how pages are executed in ASP.NET. If the object is to be stored per-user, store it in the Page.Session dictionary property instead. When the session expires the object will not be available. In you're using ASP.NET 2.0, look into the personalization feature. You can get an overview and read a tutorial at http://msdn.microsoft.com/library/en-us/dnvs05/html/person_fin.asp[^].
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
just use the namespace and the class then u will get the object of your class.
eg if
namespace WinTest
{
class abc{
public test mytest = new mytest();
}
}
class test
{
public int i;
}
now in class2 u can get the object as follows
WinTest.abc.mytest.i;
hope it will help
|
|
|
|
|
thanks nbobby,
this looks just like what I'm after.
best regards,
John
John
|
|
|
|
|
Keep in mind that this is a different instance, not the same instance created in the other page. A class and a class instance (as you mentioned in your subject) are two different things. Classes can be referred to from anywhere so long as the assembly in which the class is defined can be loaded, and that the class is not inaccessible due to its accessibility modifier (like an internal class). To keep the same instance you need to keep the instance alive. For per-user instances you can use the Page.Session variable. See my other reply for more details.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Heath you r correct ... i cant access the value that i set for the object variable in the class2.
What does this mean ...
im creating the Windows application
|
|
|
|
|
In order to access an instance of a class you must access the instance itself. Being able to use the class doesn't mean anything (unless it's a singleton, which is accessed different depending on the context). In a Windows Forms appliation this is much different than an ASP.NET application, where each page (or other handled type) is short-lived and runs in a separate thread for only as long as the page is processed. Instances of pages are not kept alive like Windows Forms. To access an instance of a class (an object) within another form you must pass a reference to that object, or to the form in which the field or property that returns that object is accessible (public or internal).
Windows Forms appliations and ASP.NET web applications are very different from each other, regarding how they are executed. They even run within different CLR hosts. MSDN has lots of information about the execution models for both types of applications.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
very helpful info Heath,
thanks
(I'm using session!)
John
|
|
|
|
|
Thanks Heath
I used the same refernce pass in windows application
|
|
|
|