|
instead of writing such lines please suggest me link for same or give answer to question,that helps me more.....
|
|
|
|
|
If you don't have the common sense to work out what to do based on having been told what is wrong, I'm not sure what else to say. Your dataset is empty. What do YOU think you should do ( apart from writing code that is more robust ) ? How about fixing your SQL ?
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
First add a DataTable to your dataset.
Rajesh B --> A Poor Workman Blames His Tools <--
|
|
|
|
|
I assume his dataset is coming from a database, what he needs to do, is fix his SQL
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Where do you add a DataTable to you DataSet ? Nowhere; that's why you are getting a problem.
DataSet.Tables is a read-only property (as shown in the documentation[^]), so mysdset.Tables["tblImgData"].Rows[0]["Picture"] = GetImageData(s); would fail anyway.
I hope this clears things up a little:
DataTable dt = new DataTable("tblImgData");
dt.Columns.Add("Picture", typeof(Byte[]));
dt.Rows.Add(GetImageData(s));
DataSet ds = new DataSet("NewDataSetName");
ds.Tables.Add(dt); NOTE: I wrote this on the fly so it may not be syntactically correct.
If at first you don't succeed, you're not Chuck Norris.
|
|
|
|
|
|
how can i printing a (contorl of webform as well as data save)on submitbutton +asp.net with c# please help me
sudhir kumar
|
|
|
|
|
1. There is an ASP.Net forum.
2. There is a lot available on web related to this. See[^].
3. Have you tried anything?
modified on Saturday, June 27, 2009 3:09 AM
|
|
|
|
|
Following the instructions in Christophe Geers’ blog, based on an article by Pavel Zolnikov on CodeProject, I have created an IE Toolbar using C# in VS 2008.
When I run IE 7 (over Vista Home on a 64 bit laptop) and go View => Toolbars,
I see my toolbar listed (right along with the others, like the Google toolbar) but I cannot put a check mark beside my toolbar.
thanks for whatever help anyone can give me.
j2
|
|
|
|
|
hi...
my application needs the user to sign in (according to sql DB) before he start using the application
SqlConnection con1 = new SqlConnection("DATA SOURCE = MAX_TOSHIBA;Initial Catalog= nodule ; Integrated security = True");
SqlDataAdapter adp1 = new SqlDataAdapter();
SqlCommand com1 = new SqlCommand();
com1.CommandText = "SELECT * FROM user WHERE name=" + txt_username.Text + " ";
com1.Connection = con1;
adp1.SelectCommand = com1;
DataSet d1 = new DataSet();
adp1.Fill(d1);
then check the d1 if null or not
any way it give me an error at
adp1.Fill(d1);
the error
System.Data.SqlClient.SqlException was unhandled
Message="Incorrect syntax near the keyword 'user'."
another qustion do any one have a good demo for the data binding?
thanx 
|
|
|
|
|
Well, your code has a LOT of issues. The first one is that user is a keyword, so you need to put it in square brackets. select * from [user] where...
The next problem you have is that you're hard coding your connection in the same code as the SQL. Do you use the database anywhere else, at all ? Could you ever ? What if you change your data source, as you're bound to do ( or will every machine you ever deploy to be called 'MAX_TOSHIBA' ??? ). So, you need to factor this code out.
Your next issue is that, based on this code, I can start with your app, and either guarentee myself a login, or at least erase your database. You need to read on SQL injection attacks.
I assume this is not being written for your job, you're a long way from being able to write production quality code. If you're teaching yourself, I'd recommend buying some good books. If you're in a class, then I think you're being moved into learning SQL before you've been taught how to write half decent C#, but I assume it will all work out in the end.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
A_A wrote: com1.CommandText = "SELECT * FROM user WHERE name=" + txt_username.Text + " ";
if i am not correct, the user is a keyword used in SQL so change the column name ot use [user] and try again.
|
|
|
|
|
Why tell him exactly what I told him 30 min before ?
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
sorry, i din't refresh the page before giving the reply...
|
|
|
|
|
thank you both
but what if i change "user" to "user_1"
should I use "[user_1]"
thank in advance
|
|
|
|
|
no you dont have to use tat. If you are using SQL Server Management Studio
and creating tables it will automatically convert user to [user].
|
|
|
|
|
thanks 
|
|
|
|
|
Guys, I need help. I know the volume letter. How can I get a model of physical disk drive which consists a volume with a known to me name? I think, I have to use WMI, maybe Win32_DiskDrive, but how can I compare logical disk with physical disk?
|
|
|
|
|
Hello
Hope this help ...
I know it's far a bit from your answer ...
But I really tried to help you as much as I can ,,
1)
using System;
using System.Collections.Generic;
using System.Text;
using System.Management;
namespace ConsoleApplication31
{
class Program
{
static void Main(string[] args)
{
ManagementScope scope = new ManagementScope(@"\root\cimv2");
ObjectQuery query = new ObjectQuery("select * from Win32_DiskPartition");
ManagementObjectSearcher searcher = new
ManagementObjectSearcher(scope, query);
ManagementObjectCollection drives = searcher.Get();
foreach (ManagementObject current in drives)
{
Console.WriteLine("device id = " + current["deviceid"]);
ObjectQuery associators = new ObjectQuery("ASSOCIATORS OF {Win32_DiskPartition.DeviceID=\"" + current["deviceid"] + "\"} where assocclass=Win32_LogicalDiskToPartition");
searcher = new ManagementObjectSearcher(scope, associators);
ManagementObjectCollection disks = searcher.Get();
foreach (ManagementObject disk in disks)
{
Console.WriteLine("\tdevice id = " + disk["deviceid"]);
}
}
}
}
}
2) Another Example ...
using System;
using System.Collections.Generic;
using System.Text;
using System.Management;
namespace ConsoleApplication31
{
class Program
{
static void Main(string[] args)
{
ManagementScope scope = new ManagementScope(@"\root\cimv2");
ObjectQuery query = new ObjectQuery("select * from Win32_DiskPartition");
ManagementObjectSearcher searcher = new
ManagementObjectSearcher(scope, query);
ManagementObjectCollection drives = searcher.Get();
int dindex= 0;
foreach (ManagementObject current in drives)
{
dindex = int.Parse(current["DiskIndex"].ToString());
}
scope = new ManagementScope(@"\root\cimv2");
query = new ObjectQuery("select * from Win32_DiskDrive WHERE Index = " + dindex.ToString());
searcher = new
ManagementObjectSearcher(scope, query);
drives = searcher.Get();
foreach (ManagementObject current in drives)
{
Console.WriteLine(current["Model"].ToString());
}
}
}
}
I know nothing , I know nothing ...
|
|
|
|
|
Thank you very much for your examples. It was really helpful to me. I combined and modified your solutions and wrote this code:
string VolumeName = "C:";
ManagementScope scope = new ManagementScope(@"\root\cimv2");
ObjectQuery query = new ObjectQuery("ASSOCIATORS OF {Win32_LogicalDisk.DeviceID=\"" + VolumeName + "\"} where assocclass=Win32_LogicalDiskToPartition");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
ManagementObjectCollection drives = searcher.Get();
foreach (ManagementObject current in drives)
{
scope = new ManagementScope(@"\root\cimv2");
query = new ObjectQuery("ASSOCIATORS OF {Win32_DiskPartition.DeviceID=\"" + current["DeviceID"].ToString() + "\"} where assocclass=Win32_DiskDriveToDiskPartition");
searcher = new ManagementObjectSearcher(scope, query);
drives = searcher.Get();
foreach (ManagementObject current2 in drives)
{
MessageBox.Show(current2["model"].ToString());
}
}
|
|
|
|
|
well done, you got my 5....
|
|
|
|
|
I want to create a structure where the elements are bitfields of arbitrary length - e.g. 12 bits followed by 4 bits which would be used as a union with an array but cannot see a neat with to do this.
Any suggestions?
Thanks.
Elaine
|
|
|
|
|
Hi Elaine,
1.
you can manually create C-style unions in C# using explicit offsets, here is an example:
[StructLayout(LayoutKind.Explicit)]
struct unie {
[FieldOffset(0)]
public float f;
[FieldOffset(0)]
public byte b;
}
You would be taking full responsibility for the correctness of the offsets! (Mind x86/x64 if you are going to store pointers/references)
2.
I am unaware of a proper way to handle bit fields, other than doing it all with ANDs and SHIFTs. Struct/class properties can hide that stuff for the outside world.
3.
Maybe this Masks and flags using bit fields in .NET[^] can inspire you.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Thanks Luc.
I've looked at 2 and 3, its' jsut that this would be so much simpler in C++
|
|
|
|
|
I've written a program in c#.net whcih uses a pre-designed sql database.
The problem is that I have added a SqlServerProject which attaches my database's mdf file to the local server and it works properly since when I run the program in the visual studio , it attaches the specified file , but the problem is that I don't know what to add to my SetupProject in order to attach the database to local server as the visual studio does as well as installing required files on the target machine?
|
|
|
|