|
You haven't said what the application does, or what technology it is. This may seem minor to you, but it will affect the answers you get if you don't provide vital information.
|
|
|
|
|
The application itself is based on WinForms. I needed an alternative for buttons, message boxes and so on. Now, I, by myself, have found Telerik RadControls pretty useful, finally after too much googling ![Smile | :)](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
atoi_powered wrote: I, by myself,
That is because you asked for an entire UI, you should have asked for a control suite. Telerik is a good choice, there are quite a few others out there as you have no doubt found.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
As CodeProject doesn't have a telepathic interface installed yet, you would have to find this out for yourself. The moral here, if you want useful help, ask a decent question.
|
|
|
|
|
I am looking for good example or articles where Database programming with all operations on multiple tables is depicted using Isolated Storage.
Please suggest some good articles.
|
|
|
|
|
|
SqlConnection conn = new SqlConnect(
"Integrated Security=SSPI;Data Source=DBSRV1;Initial Catalog=master");
SqlCommand cmd = conn.CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "sp_attach_db";
cmd.Parameters.Add("@dbname", SqlDbType.NVarChar, 128).Value = "MyDB";
cmd.Parameters.Add("@filename1", SqlDbType.NVarChar, 260).Value =
@"C:\Program Files\Microsoft SQL Server\MSSQL\Data\MyDB.mdf";
cmd.Parameters.Add("@filename2", SqlDbType.NVarChar, 260).VAlue =
@"C:\Program Files\Microsoft SQL Server\MSSQL\Data\MyDB.ldf";
try
{
conn.Open();
cmd.ExecuteNonQuery();
}
finally
{
conn.Close();
}
This is OK but i need to get the DataBase Name and File Name from TextBox,i Tried but its not working any Help
|
|
|
|
|
pranee24 wrote: i Tried but its not working any Help
Without seeing some of your code we cannot begin guess what is not working.
|
|
|
|
|
pranee24 wrote: i Tried but its not working
Does not tell anyone what you tried or why you think it's not working.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
modified 12-Jul-12 14:39pm.
|
|
|
|
|
Why is your message type "General" rather than "Question"?
pranee24 wrote: i need to get the DataBase Name and File Name from TextBox
1. So you shouldn't be using string literals then, rather use string variables, load them from the textbox(es), and feed them to your SqlCommand parameters.
2. Are you sure you want the users to have the liberty to enter anything they like? When I need access to a small number of databases, I tend to offer a choice (say a ComboBox), and have basically a switch in my code.
pranee24 wrote: its not working
interesting.
|
|
|
|
|
try this:
string dbName = txtDbName.Text.Trim();
string fileName1 = txtFileName1.Text.Trim();
string fileName2 = txtFileName2.Text.Trim();
SqlConnection conn = new SqlConnect(
"Integrated Security=SSPI;Data Source=DBSRV1;Initial Catalog=master");
SqlCommand cmd = conn.CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "sp_attach_db";
cmd.Parameters.Add("@dbname", SqlDbType.NVarChar, 128).Value = dbName;
cmd.Parameters.Add("@filename1", SqlDbType.NVarChar, 260).Value = fileName1;
cmd.Parameters.Add("@filename2", SqlDbType.NVarChar, 260).Value = fileName2;
try
{
conn.Open();
cmd.ExecuteNonQuery();
}
finally
{
conn.Close();
}
Note: Assuming user sending required/valid data from the above textboxes
|
|
|
|
|
Hello members,
I am developing Asp.net website application with framework 4.0 in Visual studio 2010. I would like to convert App_Code to single DLL which contains class files and dataset. Is it possible? Please give your suggestions
Thanks
modified 13-Jul-12 1:24am.
|
|
|
|
|
yes you can make DLL file of all the classes. this will help you to protect your code from others
hope dis link will help you
http://www.c-sharpcorner.com/uploadfile/mahesh/dll12222005064058am/dll.aspx
|
|
|
|
|
Just build the web app. That will already copy it into a single dll. You don't need to do anything special.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
hello
I whould like to convert the requete execute reader to liste:help me please.
this me requete:
System.Data.SqlClient.SqlCommand comm = new System.Data.SqlClient.SqlCommand("SELECT libelle_titre FROM titre", ConnectBase.getinstance().Connection());
List<int> liste= new List<int>();
affiche_titre = comm.ExecuteReader();
while (affiche_titre.Read())
{
liste.Add(Convert.ToInt32(affiche_titre["libelle_titre"].ToString()));
titre1.Text = liste[0]ToString();
titre2.Text = liste[1].ToString();
titre3.Text = liste[2].ToString();
thanks
|
|
|
|
|
Uh ... what's the question? You're already moving the results into a list.
|
|
|
|
|
my question hwo to execute my requete in the list and
any result in the texBox :
example:
..............
..................
System.Data.SqlClient.SqlCommand comm = new System.Data.SqlClient.SqlCommand("SELECT Title FROM titre", ConnectBase.getinstance().Connection());
rs = comm.ExecuteReader();
while (rs.Read())
string []tab = rs.ToString()
texBox1.Text= tab[0];
texBox2.Text= tab[1];
texBox3.Text= tab[2];
......
...
Thanks
|
|
|
|
|
I hate to criticize someone who has asked for help but this anti-pattern needs to stop. I am referring to:
<br />
Convert.ToInt32(affiche_titre["libelle_titre"].ToString());<br />
Data reader values already contain the object type. Look it up from the query. As for accuracy, the code doesn't seem wrong, unless you didn't bother to open your connection. My patter for this would be:
<code>
using(SqlConnection connection = new SqlConnection(connectionString){
connection.Open();
SqlCommand command = connection.CreateCommand();
command.CommandText = "your sql statement";
using(SqlDataReader reader = command.ExecuteReader()){
while(reader.Read()){
list.Add((Int32)reader[0]);
}
}
}
</code>
|
|
|
|
|
Even slightly more elegant would be:
using(SqlConnection connection = new SqlConnection(connectionString)) {
connection.Open();
using (SqlCommand command = new SqlCommand("your sql statement", connection)) {
using(SqlDataReader reader = command.ExecuteReader()){
while(reader.Read()){
list.Add((Int32)reader[0]);
}
}
}
}
as SqlCommand also implements IDisposable, and offers a constructor that takes both the SQL statement and the connection.
|
|
|
|
|
I omit the using on SqlCommand for brevity since its sole function is to close the connection. However, on the data reader, there are times when you want to re-use the command but you can't re-use a command with an open reader. This lets it be much, much easier to not have to fix that bug.
With regard to the constructor, it is matter of taste and I will never fault anyone for using it. Unfortunately, I a lot of my code is left to be maintained by others. I like to think that the brilliance in the code I write is not only in its function but in the ability to line-by-line debug without any surprises.
In my younger career I used to use stored procedures exclusively. I have now moved to embedding the SQL statments in the source files for easier version control. With this, sometimes comes complex dynamic sql statements. (Especially, when reading from SQL Server and then Selecting from Oracle, ugh) with a monstrosity like that, I really don't want to use the constructor because then you have to step into a method in a constructor to see what it does when stepping over an examining the results is so much easier.
Finally, and I never use it, don't forget the option to immediately close the command in command.ExecuteReader().
<br />
command.ExecuteReader(CommandBehavior.CloseConnection);<br />
Really, there are so many great ways to write good clean code using data readers over the hide-and-seek approach that so many ORM's use that I am surprised more developers don't just go back to the basics. I have spent more time debugging one bug in Entity Framework than in debugging every line of the code we are discussing ever. (Ok, that is hyperbole but you get my drift)
|
|
|
|
|
I mostly feel the same; I haven't used an ORM yet, I avoid adding code that isn't mine when I can get things done easily myself, as that reduces the amount of foreign things I need to know and keep track of.
|
|
|
|
|
Ennis Ray Lynch, Jr. wrote: In my younger career I used to use stored procedures exclusively. I have now
moved to embedding the SQL statments in the source files for easier version
control.
Huh?
Why doesn't putting your SQL into version control work?
|
|
|
|
|
Nice
I would like to add that you can often program against the IDbConnection and IDbCommand -interfaces here. One would only need to create a connection of the correct type, the CreateCommand factory could then be used to get a DbCommand of that type.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Yep, I have been experimenting a bit with the interface-style DB operations, and it works well most of the time. IIRC I had to use real commands to get all the metadata I wanted, things such as GetSchema.
|
|
|
|
|
hello
i have a problem in this code
i don't enjoy the result in the texBox
System.Data.SqlClient.SqlDataReader affiche_titre;
System.Data.SqlClient.SqlCommand comm = new System.Data.SqlClient.SqlCommand("SELECT libelle_titre FROM titre", ConnectBase.getinstance().Connection());
ListBox list = new ListBox();
DataTable titre = new DataTable();
affiche_titre = comm.ExecuteReader();
string [] row = null;
while (affiche_titre.Read())
{
row = new string[list.Items.Count];
for (int i = 0; i < list.Items.Count; i++)
{
row[i] = list.Items[i].ToString();
}
titre1.Text = row[0];
titre2.Text = row[1];
titre3.Text = row[2];
titre4.Text = row[3];
titre5.Text = row[4];
titre6.Text = row[5];
thans
|
|
|
|