|
I am having doubt in c# i have an database with one table
contains two fields no(primary key) and name.
so now when i enter no in the text in interface.
i have to check wether the given value is in already exist
please send detail in c#...
hai all please clarify mny doubts
|
|
|
|
|
And why do you hate using primary key, when primary key is the key to your problem
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
I think that he actually has a primary key, named "no".
---
single minded; short sighted; long gone;
|
|
|
|
|
dhulipudi wrote: I am having doubt in c#
Why do so many write "doubt" when they mean "question"?
dhulipudi wrote: i have to check wether the given value is in already exist
Make a query that counts how many records there are with that number. Example:
"select count(*) from SomeTable where no = 42"
The result is either zero or one, which tells you if the record exists or not.
---
single minded; short sighted; long gone;
|
|
|
|
|
when i enter any number in text box have to show message wether the given value is intext box are not...have to check the textbox value with database value...
hai all please clarify mny doubts
|
|
|
|
|
Use Guffa's query he provided you. Just substitute the 42 with the value in the textbox...
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
I have a file (myFile.txt)in every subfolder:
MainFolder
<subfolder1>
<sunfolder2>
<subfolder3>
I want to search every subfoler an delete the file myFile.txt
any help is greatly appreciated
using VS2003
|
|
|
|
|
Check out these methods:
File.FileExists
File.Delete
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
Hello!
i added items in combobox from treeview.
but i have a problem in combox because; when i enter 2 or more times same text in treeview nodes,combobox is adding 2 or more times these texts, too. i want that, texts return only one time. how can i do?
thanks
|
|
|
|
|
Hi,
I developed an application that receives a lot of transactions and generates C# code to perform a dynamic execution in order to create the requested response. The C# code is generated matching the request data with several rules define by the users.
I used some profiler to find a memory leak that were happening with the app. Generating some snapshots I found memory problems with reflection.
When I executable performed the CodeDomProvider.CompileAssemblyFromSource the memory seems to be very afected, It seems that any assembly loaded into a given cannot be unloaded once it's been loaded with .NET runtime.
This kind of programming could work for few transaction per hour, but when it refers to several transaction per seconds this will be a real problem.
Is there someway to dynamically execute C# code and preserve a lightweight execution and good performance?
I was considering developed a parse/compiler because the complexity that could achive the generated source code, but First of all, I want to find out if there is something in C# that already do that?
Generated Code sample: The values of the variables are filled with the incoming transaction data.
" int x = 13, y = 3, z = 200; if ( ((x*y) > z) && (z < 200) && ( x > y) ) return 1;"
Thanks.
rmga
|
|
|
|
|
rmga wrote: It seems that any assembly loaded into a given cannot be unloaded once it's been loaded with .NET runtime
While an assembly cannot be unloaded once it is loaded into an application domain, you can create a new application domain, load the assembly into it and the unload the entire domain. I do not know the performance of this only that it can be done.
-- modified at 23:26 Friday 25th May, 2007
topcoderjax - Remember, Google is your friend.
|
|
|
|
|
Hello,
I have a COM+ application built using C# and the MSI for it runs just dandy, its basically a COM proxy for .NET to ASP. However, when running a test VBScript, I get the following message whenever I attempt to execute one of the methods (object seems to get created though)..
on this line: set objCreditAppEntity = objComProxy.GetSavedApplication(1, "CITDE")
with this message: Error retrieving certificate with ID <> from location LocalMachine
and this stack trace:
System.Configuration.ConfigurationException
Stack Trace:
at CIT.EAI.Crypto.CertificateManager.RetrieveCertificateFromStore(X509CertificateStore store, String keyIdentifier)
at CIT.EAI.Crypto.CertificateManager.GetDefaultCertificate()
at CIT.EAI.Web.Security.WseUtilities.GetClientToken()
at CIT.EAI.Web.Security.WseUtilities.ConfigureProxy(WebServicesClientProtocol protocol)
at CIT.EAI.EFCanada.ComProxy.RepositoryFactory.GetCreditAppWS()
at CIT.EAI.EFCanada.ComProxy.EFCanadaComProxy.GetSavedApplication(Int32 creditAppId, String applicationCode)
Any ideas why? seems to be a WSE thing, but I'm lost as I'm still kind of a newbie to COM, etc...This proxy talks to three web services by the way.
VBScript test code given below
----------------------------------------------
Dim objComProxy
Dim arrContact
Dim errCode
Dim objCreditAppEntity
Dim objCreditAppEntityList
Dim objQuoteEntity
Dim objQuoteEntityList
dim xmlDoc, sPath, sFile, sInFileName
Set objComProxy = CreateObject("CIT.EAI.EFCanada.ComProxy.EFCanadaComProxy")
'ERROR HERE
set objCreditAppEntity = objComProxy.GetSavedApplication(1, "CITDE")
WScript.Echo "Credit app ID: " & objCreditAppEntity.CreditAppId
WScript.Echo "Credit app status code: " & objCreditAppEntity.CreditAppStatusCd
|
|
|
|
|
I am writing an application in C#.NET. I am using .NET DataBindings in addition to direct calls to the database. My application currently uses SQL Server as the back end. I would like my application to also support MS Access as a back end. I'm having a difficult time getting the databindings to work with either SQL Server or MS Access. Any tips/advice would be greatly appreciated. Thanks
|
|
|
|
|
Hi,
I am so sorry for this question. I am sure there are a million answers to it. In fact, I found some articles on it but when I tried running them, I kept getting errors. I think they were for an older version of VS because sometimes it would try to convert them when I load them up. I have done the RSS reader training from MSDN - to give you an idea of where I am regarding my knowledge level.
Here is exactly what I want to do;
I am developing my first non-training related application. It is a simple finance application but I want the user to be able to create the database with the name and location of his choice. I have read book after book and article after article about databases in VS and almost all of them use the wizard to create the database and tables, etc. The ones that don't give me compile time errors. I want the program (under user control) to create the database at runtime. He can either click on a toolbar icon or go Menu/File/New. I can do the form related things but this database thing is kicking me around the block. I looked up create database in the msdn library help and it keeps giving me t-sql commands and scripts but the user will not have sql server installed so I can't do that. It is beyond me why this is so hard for me to find.
Ciao
bb
|
|
|
|
|
Use SQL Server Express instead of Access. It's free and you can use the SQL commands you have read about.
only two letters away from being an asset
|
|
|
|
|
um..ok but how do I do that. Like I said, when I tried the examples I have seen like this one (http://www.codeproject.com/cs/database/DBInstaller1.asp), I kept getting errors.
|
|
|
|
|
Perhaps you would care to elaborate and tell us what errors. "I kept getting errors" isn't very helpful. How would you solve a problem with level of information?
only two letters away from being an asset
|
|
|
|
|
Firstly, regarding the errors related to loading up the sample I referenced in my last post, they arise from the Visual Studio Conversion Wizard. It does not specify the errors other than saying that there was a conversion error with banner.jpg
Secondly, I think I gave enough information in my original post. If you didn't read it, I will repeat it.
I am developing my first non-training related application. It is a simple finance application but I want the user to be able to create the database with the name and location of his choice. I have read book after book and article after article about databases in VS and almost all of them use the wizard to create the database and tables, etc. I want the program (under user control) to create the database at runtime. He can either click on a toolbar icon or go Menu/File/New.
If someone knows the answer, I would appreciate a proper reply - preferably with a snippet of sample code.
|
|
|
|
|
First issue. Contact the author if you havne't done so already.
Second issue. Be specific. What have you tried? What are the issues you are having?
brickbat wrote: If someone knows the answer, I would appreciate a proper reply
Proper reply? It took three posts for you mention the errors were from the conversion wizard and not code related. If you want a "proper" reply, then provide the details necessary for us to help you.
brickbat wrote: preferably with a snippet of sample code.
I find it difficult to believe that after reading all the references you say, you did not find any example of a sql statement to CREATE DATABASE.
only two letters away from being an asset
|
|
|
|
|
You are right. I did find several references to it and I can't get them to work. Here is where I got.
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Data.SqlClient;<br />
using System.Drawing;<br />
using System.Text;<br />
using System.Windows.Forms;<br />
<br />
namespace Project<br />
{<br />
public partial class Form1 : Form<br />
{<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
toolStripStatusLabel1.Text = "";<br />
}<br />
public void NewStatus()<br />
{<br />
<br />
}<br />
public void CreateDatabase()<br />
{<br />
string sCreateDatabase = "CREATE DATABASE Projectdb9"; <br />
SqlConnection mycon = new SqlConnection();<br />
mycon.ConnectionString = "Data Source=.\\SQLEXPRESS;Integrated Security=True;Connect Timeout=30;User Instance=True";<br />
<br />
SqlCommand mycomm = new SqlCommand();<br />
mycomm.CommandType = CommandType.Text;<br />
mycomm.CommandText = sCreateDatabase;<br />
mycomm.Connection = mycon;<br />
<br />
try<br />
{<br />
mycon.Open();<br />
mycomm.ExecuteNonQuery();<br />
}<br />
catch<br />
{<br />
toolStripStatusLabel1.Text = "Database Creation Error ";<br />
}<br />
finally<br />
{<br />
mycon.Close();<br />
}<br />
<br />
}<br />
<br />
private void newToolStripMenuItem_Click(object sender, EventArgs e)<br />
{<br />
CreateDatabase();<br />
}<br />
<br />
private void Form1_Load(object sender, EventArgs e)<br />
{<br />
<br />
} <br />
}<br />
}<br />
But I know its wrong. Firstly, I can't figure out where to set the path. In all the references I found, I can't find anything about setting the path so I think I am creating an SQL database on an SQL server which is NOT what I want. Thats why I didn't post my code straight away. I would rather get a simple answer to my question instead of people being confused about what I want by my code and fixing it but still leaving me with the wrong solution.
n instead of people being confused about what I want by my code and fixing it but still leaving me with the wrong solution.
|
|
|
|
|
Thankfully someone at the MSDN network pointed me in the right direction. For those that might have the same problem, here is the answer.
http://support.microsoft.com/default.aspx/kb/317881
As I thought, unless you want the user installing an SQL server on his machine, the best course is to use an access database.
Here is some code
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using ADOX;<br />
using System.Drawing;<br />
using System.Text;<br />
using System.Windows.Forms;<br />
<br />
namespace Project<br />
{<br />
public partial class Form1 : Form<br />
{<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
toolStripStatusLabel1.Text = "";<br />
}<br />
public void NewStatus()<br />
{<br />
<br />
}<br />
public void CreateDatabase()<br />
{<br />
<br />
ADOX.CatalogClass cat = new ADOX.CatalogClass();<br />
<br />
cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;" +<br />
"Data Source=D:\\Projectdb.mdb;" +<br />
"Jet OLEDB:Engine Type=5");<br />
<br />
toolStripStatusLabel1.Text = "Database Created Successfully";<br />
<br />
cat = null;<br />
<br />
<br />
<br />
}<br />
<br />
private void newToolStripMenuItem_Click(object sender, EventArgs e)<br />
{<br />
CreateDatabase();<br />
}<br />
<br />
private void Form1_Load(object sender, EventArgs e)<br />
{<br />
<br />
} <br />
}<br />
}<br />
As you can see, there is a place for the path and now I just need to add a little code to get the name and location selection from the user and its done. Well, there is the adding of tables,keys,etc to be done too.
|
|
|
|
|
As I stated orginially Access is not the best choice. Using SQL Server Express provides for better scalablity and functionality, easier programming model, etc., not to mention that the code you posted previously would have worked, without this long thread and all your self-imposed problems.
only two letters away from being an asset
|
|
|
|
|
You have not given one piece of usable advice. Are you a troll?
- You say "Use sql" but when I ask how, you give no examples and you ask me for what I have tried.
- When I ask how to specify the path for the database, you ignore it.
- When I post my erroneous code, you say it works.
Useless, Useless, Useless.
|
|
|
|
|
brickbat wrote: Are you a troll?
Trolls aren't given MVPs....
brickbat wrote: You have not given one piece of usable advice.
He has. I'll add, use SQL Express instead of Access...
|
|
|
|
|
brickbat wrote: Data Source=.\\SQLEXPRESS
This is the path. It is the local instance of SQL Server Express that has been installed on the system the applicaiton is running on. You could also use something like Data Source=MyDB.mdf for a file based database for the application.
Again, with all of the refences you have claimed to have read I find it difficult to believe this has not been explained.
only two letters away from being an asset
|
|
|
|