|
Do you really need to transfer the data int oa DataTable? You could directly write the contents of the DataView. I assume you are writing with a loop like:
foreach (DataRow dataRow in dataTable.Rows) {
}
If you have a DataView the equivalent code would look like:
foreach (DataRowView dataRowView in dataView) {
DataRow dataRow = dataRowView.Row;
}
The difference would only be the sorting.
Robert
|
|
|
|
|
How to connect a BlueTooth to a window application?
i am writing a windows application on sending images through bluetooth device connected to a PC to mobile phones. but i had problem in connecting to the bluetooth device using codes and how we are going to search for available devices and allow the users to select. Is there any available APIs where i can take reference?
|
|
|
|
|
Have a look at 32feet.net Peter Foot has spent alot of time getting the windows bluetooth api into an friendly dll.
Have a look, it also has lots of examples. Only drawback is that you have to have XP Service Pack 1 (or any operating system that comes with the Microsoft Bluetooth Stack) and that you have to uninstall your current drivers if they are not Microsoft.
It also has all the support for the MS Stack enabled pda's and smart phones that run the compact framework.
Gav
|
|
|
|
|
what is the difference between DataGrid and DataGridView?
|
|
|
|
|
The DataGrid was introduced with the first .Net framework version. The DataGridView was introduced with .Net 2.0.
There are many functionalities which are available in both grids. But both have also capabilities the other hasn't. One advantage of the DataGrid is for example that it can display DataTables of a DataSet which have relations (the user can naviagte through the different tables). The DataGridView has for example dynamic column reordering and better databinding.
Generally I'd prefer the DataGridView but it depends on your requirements which one fits better.
|
|
|
|
|
what do you mean by Dynamic column reordering?plz give an example
|
|
|
|
|
This means that the columns can be reordered by the user with drag & drop without actually modifying the underlying data source.
|
|
|
|
|
hi.i am struggling to insert name in the database using method.it gives me this error "Use of unassigned local variable 'empname'" and my code is as follows.
public void InsertValues(string empname1)
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "integrated security=SSPI;initial catalog=Employee;server = za211149;persist security info=False";
conn.Open();
try
{
SqlCommand cmdInsert = new SqlCommand();
cmdInsert.Connection = conn;
empname = empname1;
cmdInsert.CommandText = "INSERT INTO jakes VALUES(@empname)";
cmdInsert.Parameters.Add(new SqlParameter("@empname",System.Data.SqlDbType.VarChar,50,"empname"));
cmdInsert.Parameters["@empname"].Value = empname.ToString();
if (cmdInsert.ExecuteNonQuery() !=0)
{
MessageBox.Show("Record inserted");
}
else
{
MessageBox.Show("record not inserted");
}
//return true;
}
catch(Exception E)
{
MessageBox.Show(E.ToString());
//return false;
}
finally
{
conn.Close();
}
}
|
|
|
|
|
The code you posted does not contain a declaration for the variable empname
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
actually my code is like this.
using System;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Windows.Forms;
namespace bb
{
///
/// Summary description for connection.
///
public class connection1
{
public string empname;
public connection1()
{
//
// TODO: Add constructor logic here
//
}
public void InsertValues(string empname1)
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "integrated security=SSPI;initial catalog=Employee;server = za211149;persist security info=False";
conn.Open();
try
{
SqlCommand cmdInsert = new SqlCommand();
cmdInsert.Connection = conn;
empname = empname1;
cmdInsert.CommandText = "INSERT INTO jakes VALUES(@empname)";
cmdInsert.Parameters.Add(new SqlParameter("@empname",System.Data.SqlDbType.VarChar,50,"empname"));
cmdInsert.Parameters["@empname"].Value = empname.ToString();
if (cmdInsert.ExecuteNonQuery() !=0)
{
MessageBox.Show("Record inserted");
}
else
{
MessageBox.Show("record not inserted");
}
//return true;
}
catch(Exception E)
{
MessageBox.Show(E.ToString());
//return false;
}
finally
{
conn.Close();
}
}
}
}
|
|
|
|
|
Mamphekgo wrote: cmdInsert.Parameters.Add(new SqlParameter("@empname",System.Data.SqlDbType.VarChar,50,"empname"));
cmdInsert.Parameters["@empname"].Value = empname.ToString() ;
If I'm not wrong string type doesn't need conversion to string. Since it's already a string.
Initializing the variable empname with empty string might solve your problem.
Best of Luck.
_____________________________
Success is not something to wait for, its something to work for.
|
|
|
|
|
|
Michael P Butler wrote: What is wrong with the above code?
Nothing!
But does it make sense to convert into its own type? or do we have need for it?
_____________________________
Success is not something to wait for, its something to work for.
|
|
|
|
|
Hi,
Iam new to c# ,is it possible to create a tool strip which can be moved to the middle of the form (similar to the toolstrips present in microsoft products),using vs2005.
thank you,
Regards
praveen
|
|
|
|
|
Hello,
I'm getting the following exception when I'm running my app:
SetCompatibleTextRenderingDefault must be called before the first IWin32Window object is created in the application.
I followed I tutorial to create a splash screen and my Program.cs file has been changed to:
static class Program
{
private static ApplicationContext context;
private static SplashForm sForm = new SplashForm();
private static MainForm mForm = new MainForm();
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
context = new ApplicationContext();
Application.Idle += new EventHandler(OnAppIdle);
sForm.Show();
Application.Run(context);
}
private static void OnAppIdle(object sender, EventArgs e)
{
if (context.MainForm == null)
{
Application.Idle -= new EventHandler(OnAppIdle);
mForm.PreLoad();
context.MainForm = mForm;
context.MainForm.Show();
sForm.Close();
sForm = null;
}
}
}
Everything is working fine, except when I uncomment this line:
Application.SetCompatibleTextRenderingDefault(false);
I get the exception mentioned above.
How can I solve that?
Thanks in advance.
|
|
|
|
|
The tutorial is wrong or you did not follow it correctly. Never had that probelem but from the code and the error message I would guess you can't have statically constructed forms if you want to call SetCompatibleTextRenderingDefault().
make sure you post the solution when you find it.
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
This is the tutorial:
http://www.codeproject.com/csharp/apploadingarticle.asp
It was written for .NET 1.1 and I tried to convert it to version 2.0. I just didn't create a class named: AppLoader I used Program.cs instead.
Thanks.
|
|
|
|
|
Hi,
What is the difference between value types and structs in C#?
_____________________________
Success is not something to wait for, its something to work for.
|
|
|
|
|
a struct is a value type, but so is an int or a double.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
|
Thanks,
Thats more precise and clear.
Best Regards.
_____________________________
Success is not something to wait for, its something to work for.
|
|
|
|
|
With the minor exception that ValueType is an actual type that structs extend. Reference type is only a concept... Well not only, but there is no ReferenceType class. Or would object count? ehh, food for thought.
Try code model generation tools at BoneSoft.com.
|
|
|
|
|
BoneSoft wrote: With the minor exception that ValueType is an actual type that structs extend.
Got it, thanks.
And what i have little knowledge about a class is, its like a template for similar objects. Objects are called Reference types. Is that right?
Regards.
_____________________________
Success is not something to wait for, its something to work for.
|
|
|
|
|
All things .Net extend object, even ValueType. Ints and decimals and string, everything.
A class is the cookie cutter, objects are the cookies.
The primative types like int decmial and the like, plus anything that extends ValueType like enums and anything declared as a struct, are all value types. All interfaces and classes are reference types because they are always heaped. Balue types are meant to be simple because they are stacked.
Try code model generation tools at BoneSoft.com.
-- modified at 10:06 Thursday 29th June, 2006
Balue = Value
|
|
|
|
|
i am using a monthcalendar control in my form. and its my first time to use such control.
how would i be able to know what year is the current display of the calendar
after i clicked the buttons from either side of the navigation button?
one of the functionality of the form is also to save holidays on a certain date. and to determine that date to be a holiday, i should change the backcolor of the specific date of the calendar. how would i be able to do such?
thanks in advance.
|
|
|
|