|
RajKat wrote: datagridview1.Rows(0).Cells(0).Style.BackColor = Color.Orange
Try brackets rather than parenthesis:
datagridView1.Rows[0].Cells[0].Style.BackColor=Color.Orange;
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
I have an application written in C# with SQL server Dbase . Would like to convert the same application to Web Enabled as ASP.NET without having to Re-write the code again in ASP.NET . Can anyone help in that ?
UnitecSoft
We will Either Find A Way , Or We Will Make One .
|
|
|
|
|
If you designed it properly then all you need to to is slap on a different UI - All your business logic and database interaction should be separate from your UI.
|
|
|
|
|
unitecsoft wrote: I have an application written in C# with SQL server Dbase . Would like to convert the same application to Web Enabled as ASP.NET without having to Re-write the code again in ASP.NET . Can anyone help in that ?
Your question is a little broad and doesn't provide a lot of information about the design of your current app. As Colin says, if your app has been designed well and seperates UI, Data Access and Business logic then it should be a fairly straight forward job to replace the existing UI with a web front end. (Although that depends on the complexity of the UI as the stateless nature of HTTP can make it hard to convert a WinForm to a WebForm directly)
|
|
|
|
|
Basically, there is no tool to convert a Windows Forms app to an ASP.NET app. The ways each work with it's own forms are so different, a direct translation is not possible. You're stuck re-writing your application.
But, as Colin said, if your application was written properly, meaning that you kept your business and data logic in classes seperate from your application code, you've minimized the work you have to do rewriting your UI code. Properly written Business Logic and Data Access layers will be completely independant of the User Interface code. This way, you only need to write a new UI layer if you want to support multiple types of clients, like Windows Forms, ASP.NET, Pocket PC's, mini browsers (cell phones), or Embedded systems.
Google for "3-Tier" and "n-tier" application development and you'll find TONS of resources on how to properly write applications that support this.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
How to convert Int to DateTime and vice versa?
Thanks and Regards
Madhu
|
|
|
|
|
Depends on how the DateTime is represented in the int.
|
|
|
|
|
Hello
What's the format of the integer? Is it YYYDDMM, days, monthes, weeks???
Regards
|
|
|
|
|
Can anybody tell me something about Microsoft Code Blocks?
kumar
(Beginner)
|
|
|
|
|
|
Whoa! It's all in sanscript/Arabic, and it's right-to-left!
|
|
|
|
|
kumar.bs wrote: Can anybody tell me something about Microsoft Code Blocks?
Do you mean application blocks[^]?
What do you want to know?
As the site says
Application Blocks are reusable source-code components that provide proven solutions to common development challenges. They can be integrated as is into applications, or they can be extended or customized. patterns & practices Application Blocks address specific recurring problem domains such as data access, logging, user interface process, and composite user interfaces.
|
|
|
|
|
Hi,
I am trying to run a select query on a datatable.
The datatable holds information I get from an Access database.
My code:
<br />
OleDbConnection myConn = new OleDbConnection();<br />
myConn.ConnectionString = "Provider=Microsoft.JET.OLEDB.4.0;data source=" + DBPath;<br />
<br />
OleDbCommand myCommand = new OleDbCommand();<br />
myCommand.Connection = myConn;<br />
myCommand.CommandText = "Select * from [tblMembers] where Active = false";<br />
myCommand.CommandType = System.Data.CommandType.Text;<br />
System.Data.DataTable myTable = new System.Data.DataTable("myTable");<br />
<br />
OleDbDataAdapter myDataAdapter = new OleDbDataAdapter(myCommand);<br />
myDataAdapter.Fill(myTable);
I have to query three columns in the datatable (MemberID, MemberLanguage, MemberName), and bind those info to the following variables:
intMemberID, strMemberLanguage, strMemberName
How can I do this?
|
|
|
|
|
Hello
You can do that using OleDbCommand.ExecuteReader() that will return a DataReader object. Using it you can get your results.
About the columns selection, then you sould modify your SELECT statement. Binding them to these three variables is quite unclear. Data binding is done with bindable controls, not variables.
Regards
|
|
|
|
|
Nothing wrong with using the DataTable he has. The DataReader is a connected object which may not be optimal for the situation.
only two letters away from being an asset
|
|
|
|
|
Nader Elshehabi wrote: You can do that using OleDbCommand.ExecuteReader() that will return a DataReader object. Using it you can get your results.
About the columns selection, then you sould modify your SELECT statement. Binding them to these three variables is quite unclear. Data binding is done with bindable controls, not variables.
This is not really what I wanted, I already have the info in the datatable, I just need to query it, using some sort of select statement, where I can select the current row that has the values I need, and bind those values to variables.
|
|
|
|
|
intMemberID = Convert.ToInt32(myTable.Row[0]["MemberID"]); ...
only two letters away from being an asset
|
|
|
|
|
I'd be extremely surprised if that's what he was asking about?!! I had all sorts of guesses jumping in my mind of what really he was asking about. A guy who makes an SqlConnection didn't know how to convert a string to Int32?!!
Regards
|
|
|
|
|
Nader Elshehabi wrote: I'd be extremely surprised if that's what he was asking about?!! I had all sorts of guesses jumping in my mind of what really he was asking about. A guy who makes an SqlConnection didn't know how to convert a string to Int32?!!
I am not sure if you were talking of my message, but what I meant was. I have a datatable, already filled with information from the database. Now I need to use some of the data in that datatable, bind to a variable I can use throughout my application. I am building the app as a windows app.
The problem is, I have a MemberID(it's unique and primary key), that I need to use to get the member's language and name from the datatable. So I wanted to do something like
SELECT MemberID, MemberLanguage, MemberName FROM "mytable" where MemberID = strCurrentMemberID<br />
'mytable = the datatable
I dont know how to do this select from a datatable.
|
|
|
|
|
playout wrote: SELECT MemberID, MemberLanguage, MemberName FROM "mytable" where MemberID = strCurrentMemberID
'mytable = the datatable
That should do it
only two letters away from being an asset
|
|
|
|
|
Thanks, this might be helpful, only problem is, I dont know what row the value is in, so how can I search via row?
EG: The member details for the current row can be in row 5 or 68 for that matter, the only reference I have, is an employee number.
|
|
|
|
|
Given your scenario and my understanding of it, if you have more that one record returned then you have something wrong in your database.
only two letters away from being an asset
|
|
|
|
|
Please help! How can i access metod UpdateRows from another thread in this code?
Thanks.
using ...
namespace pddServer
{
public partial class Form1 : Form
{
public class ThreadedTcpServer
{
public void StartServer()
{
ConnectionThread newconnection = new ConnectionThread();
Thread newthread = new Thread(new ThreadStart(newconnection.HadnleConnection));
newthread.Start();
}
class ConnectionThread
{
public void HadnleConnection()
{
connections++;
//
// How can i call method UpdateRows from this place?
//
connections--;
}
}
}
private Thread ServerThread;
public Form1()
{
InitializeComponent();
ThreadedTcpServer Server = new ThreadedTcpServer();
ServerThread = new Thread(new ThreadStart(Server.StartServer));
ServerThread.Start();
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
ServerThread.Abort();
}
public void UpdateRows()
{
dataGridView1.Rows.Add();
}
}
}
|
|
|
|
|
Hello
Your multithreading module is not right IMO. Your thread must be an object in your From class, not in a separate class. Then it should know about the UpdateRows method's existence and call it using this.Invoke() .
Regards
|
|
|
|
|
Ok, I created a sql server database connection object for all to use if you're interested however I'm posting this on here with the hopes that people try to make improvements upon it and can share their changes with me. I've only been coding in C# for a little while now so I'm hoping for some advice on where I can make improvements.
Currently, it's only compatible with SQL Server & requires a stored procedure and it then reads a connection string stored in either the web.config or app.config file.
It can return data as a datatable or dataset or return nothing at all. Each method can accept up to 10 arguments to be passed into a stored procedure. If a user needs to declare more than 10 arguments, they must pass them in as an array.
So for those who don't know, a sample web.config file would be setup like this (although I recomend encrypting your config file if you use this on a server):
------------------------------------------------------------------
<configuration>
<appSettings/>
<connectionStrings>
<add name="SqlServerConnection"
connectionString="Data Source = yourDataSource;Initial Catalog = dbName;User Id =yourUserId;Password = yourPWord;"
providerName="System.Data.SqlClient"/>
</connectionStrings>
-------------------------------------------------------------------
You can then create an instance of the DBConn object like the following:
----------------------------------------------------------------------
DBConn dbConnection = new DBConn("SqlServerConnection");
DataTable dtTable = dbConnection.PopulateDataTable("storedProcName", argument1);
----------------------------------------------------------------------
The file can be located at http://www.jennyperl.com/stuff/DBConn.zip
I'd greatly appreciate any advice/additions that can be made to this to help improve upon it. If you simply wish to use it as is and make no improvements, I hope it helps make your coding a little easier.
If you wish to contact me personally, you can email me at goalie35_33@yahoo.com.
Thanks.
-Goalie35
|
|
|
|