|
Hi,
To verify my parametres given in my connection string,I create a file .udl and I verify my connexion that is good fine and connexion works well.The problem is that the info in this file are the same that i write in my code.
I wanna ask how can I use this file in my code without need of the connexion string???
Thanks
|
|
|
|
|
Hi barts,
Finally I depass the problem of the connexion to server by the DB File's attachment . No exception apperas.Still now the problem of the filling of my combobox .I try with sqldataset instead of the sqlreader like this:
string sConnection = "Data Source=127.0.0.1,1433;Persist Security Info=True;Initial Catalog=GMAO;User ID=sa;Password=sa";
string sSQL = "SELECT com FROM energie; ";
SqlConnection conn = new SqlConnection(sConnection);
SqlCommand comm = new SqlCommand(sSQL, conn);
DataSet ds = new DataSet();
SqlCeDataAdapter da = new SqlCeDataAdapter();
SqlDataReader dr = null;
try
{
comm.Connection.Open();
da.Fill(ds, "SQL Temp Table");
foreach(DataRow d in ds.Tables[0].Rows)
comboBox1.Items.Add(d.ToString());
}
catch (SqlException ex)
{
MessageBox.Show(ex.Message);
return;
}
dr.Close();
comm.Connection.Close();
}
but nothing is added to my combobox.
Thanks in all cases for u collaboration
|
|
|
|
|
Hey,
Glad to see you've progressed!
I have a couple of commentaries:
1) 127.0.0.1 is the ip of the loopback interface, so if you use the loopback then you use no network (so this was a network problem, probably missing network connection?)
2) the data adapter da is not retriving any rows because it has no select command. You should use this line of code SqlCeDataAdapter da = new SqlCeDataAdapter(comm);
3) there is no use form the data reader dr
4) sql ce data adapter does not work with sql command or sql connection...
5) it is usefull to bind data to the combo box in order to maintain relation with your database entity.
I recommend this snippet of code:
string sConnection = "Data Source=127.0.0.1,1433;Persist Security Info=True;Initial Catalog=GMAO;User ID=sa;Password=sa";
string sSQL = "SELECT ID, com FROM energie";
SqlConnection conn = new SqlConnection(sConnection);
SqlCommand comm = new SqlCommand(sSQL, conn);
SqlDataAdapter da = new SqlDataAdapter(comm);
try
{
DataSet ds = new DataSet();
comm.Connection.Open();
da.Fill(ds);
comboBox1.DataSource = da.Table[0];
comboBox1.DisplayMember = "com";
comboBox1.ValueMember = "ID";
}
catch (SqlException ex)
{
MessageBox.Show(ex.Message);
}
finally
{
comm.Connection.Close();
}
I have no smart signature yet...
|
|
|
|
|
Hi,
I experiment u suggestion but still my combobox wants to be always empty .It refuses to be filled
what a strong combobox!!!
Thank u
|
|
|
|
|
Hi All
I need some advice, I am a administrator and not a programmer, so pardon the ignorance.
We have implemented a load balanced solution (CISCO ACE) for an SAP module, the load balancer uses a C# Web application as an HTTP probe so that it can use it to direct traffic to the application server, there is other probes for the load balancer, for example SNMP probes, but the C# web application is the primary probe.
The C# web application does the following:
It attempts to create a TCP socket connection to the SQL server
It checks to see if a service is running on the local server
It checks for the existence of a file on a UNC file share
It tries to connect to an OLAP database
If all of these checks are successful, it returns a "SUCCESS" string, the load balancer then connects to the HTTP probe and checks for the string "SUCCESS" every 10 seconds. At the moment it is working and doing what it is supposed to, but there isn’t much load, we are still currently in development. We anticipate a high level of concurrency, several thousand users.
I was wondering is this the most effective way of checking these components, would it make sense create a C# console application that runs as a service and outputs the results to a file, which the load balancer then reads?
Any Advice would be appreciated
Kind Regards and Thanks
Daniel
|
|
|
|
|
It seems to me that a single windows service could accomplish all of that, post results to the service's application log, and the load balancer could check that log.
The benefit using a windows service is that it will be automatically loaded if the system is rebooted, and you don't have to put anything in the startup folder for the machine.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Hello,
I am looking for how to write a set of data formatted on a text file..Up to now,I have been using c++ and using setprecision(..) and setw(..) commands but I could not find out how to do it in c#.In fact, My output file must be like: three different columns and sets of lines.However, Once I try to write the data on the file, the columns tend to shift to the right..I wanna keep them in order and write them neatly..I hope someone can help me to solve this problem.
|
|
|
|
|
If I am right setw sets the width of a field in c++?
and setprecision set the number of decimal digits?
If so, then you just need string.format or the ToString("formatstring") method of the various data types (int.ToString("..."), double.ToString("..."), etc.)
See Formatting_Strings_in_C_Sharp[^]
I have learnt that you can not make someone love you, all you can do is stalk them and hope they panic and give in.
Apathy Error: Don't bother striking any key.
|
|
|
|
|
thank you very much..I think that is what I want..again thanks a lot!
|
|
|
|
|
I was accessing a page at work before my vpn fully connected and got a windows login prompt. The login prompt had a list of email addresses, one of them I would not like to have there. Does any one know where this would be stored? I searched the whole registry for that exact address and nothing was found.
I am running windows xp sp3
Thanks
|
|
|
|
|
And this has what to do with C#?
Don't cross post in other forums, especially those that have no bearing on your question..
The reason why you're not getting an answer is because people who read the question don't know where that stuff is stored.
|
|
|
|
|
hi
How Can I export data from DataGridView to Acrobat Reader ? In C#, Please help me the code.
|
|
|
|
|
You need one of the PDF creator libraries. Try a Google search and select the one that suits your purposes.
It's time for a new signature.
|
|
|
|
|
This would have a lot to do with C# since someone may have developed a program that accessed such an area..written in C#. I did cross post, I needed an answer and figured if general IT people wouldn't know maybe fellow developers would.
|
|
|
|
|
Sorry I don't understand what you are saying. I gave you the answer, go and take a look, there are a number of C# libraries to do what you want.
It's time for a new signature.
|
|
|
|
|
hi friends,
I want to develop 3 tier app but I still confused how to implement it
1. In data access layer, could I return datareader? it's the better approach? some people tell it is not good way, you better used arrayList.
2. I have one method with 3 transaction inside (insert, update, delete)
I make this in business layer, so that the OleDBConnection (open and close), OleDbTransaction placed in business layer and I pass this as parameter to data access layer, is that good way?
3. if anyone have the good tutorial especially in C#, please tell me.
Thanks
|
|
|
|
|
|
OK, thank you, I check it first
|
|
|
|
|
As far as I know 3-layer architecture is something like this:
Data Access Layer(DAL) <-> Business Layer(BL) <-> User Interface Layer(UI)
Note that tier is diffrent form layer.
DAL is responsible for accessing data from the database (if there is any)
BL is responsible for applying business rules to the data
UI is responsible for displaying the data to the user and providing means for him to change it.
The data travels in special objects called Bussiness Objects.
I strongly recommend that from the DAL to not return data readers, especialy if the DAL component is on a machine and you reader reaches another component on another machine - this thing will not work in a 3-tier architecture.
You could use for the bussiness objects the dataset created by Visual Studio. The newer versions have a functionality which separate the business objects (data tables and data rows) from the table adapters in different namespaces (even different projects I think).
Also I think there isn't a "good tutorial", but different opinions, read a couple of them and then form your own.
I have no smart signature yet...
|
|
|
|
|
Thanks 4 the answer, could you give me the example?
|
|
|
|
|
As I said, there are lots of examples on the net, just google for them.
I have no smart signature yet...
|
|
|
|
|
I suggest you google for nHibernate or Linq to Entities.
These both map business objects to your relational database(ORM) with varying degrees of success, forming a DAL for you.
I have seen various DALs written with data sets, and would *strongly* advise against it, they work initially for small object sets, but becomes a nightmare as soon as the comlexity increases a little.
Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter.
Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.
|
|
|
|
|
I have heard about nHibernate but it is in java, there is in .net too?
and LINQ to Entities, this new to me, I've learn it but still not familiar with the code.I need more practice, maybe after this project done thanks
|
|
|
|
|
Hybernate is the java version. nhybernate is the .NET implementation.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
hi friends...this is my code
please tell me + -
DAL
public static OleDbDataReader GetAll(OleDbConnection conn, bool status)
{
try
{
string query =
"SELECT [Id], [Name], [CreatedDate], [CreatedBy], " +
" [UpdatedDate], [UpdatedBy] " +
"FROM [Role] " +
"WHERE [Status] = @pStatus " +
"ORDER BY [Name] ASC";
OleDbCommand cmd = new OleDbCommand(query, conn);
OleDbParameter pStatus = cmd.Parameters.Add("@pStatus",
OleDbType.Boolean);
pStatus.Value = status;
OleDbDataReader dr = cmd.ExecuteReader();
return dr;
}
catch (OleDbException ex)
{
throw new Exception("OleDb Error: " + ex.Message);
}
catch (Exception ex)
{
throw ex;
}
}
BLL
public List<Role> GetAll(bool status)
{
List<Role> listRole = new List<Role>();
try
{
if (conn.State != ConnectionState.Open)
{
conn.Open();
}
OleDbDataReader dr = RoleData.GetAll(conn, status);
if (dr.HasRows)
{
while (dr.Read())
{
Role role = new Role();
role.Id = int.Parse(dr["Id"].ToString());
role.Name = dr["Name"].ToString();
role.CreatedBy = dr["CreatedBy"].ToString();
role.CreatedDate = (string.Empty.Equals(dr["CreatedDate"].ToString()) ?
DateTime.MinValue :
DateTime.Parse(dr["CreatedDate"].ToString()));
role.UpdatedBy = dr["UpdatedBy"].ToString();
role.UpdatedDate = (string.Empty.Equals(dr["UpdatedDate"].ToString()) ?
DateTime.MinValue :
DateTime.Parse(dr["UpdatedDate"].ToString()));
listRole.Add(role);
}
}
return listRole;
}
catch (OleDbException ex)
{
throw new Exception("OleDb Error: " + "\n" + ex.Message);
}
catch (Exception e)
{
throw new Exception(e.Message);
}
finally
{
conn.Close();
}
}
|
|
|
|