|
-
Apr 11th, 2007, 04:35 AM
#1
Thread Starter
Addicted Member
[02/03] Stuck in C# code
Hi,
i am very new to C#.
Actually i have written these lines of code in class file.But it is giving error.-- near dataset word --Expected Class,enum,structure,delegate, interface,why , what may be the problem, same lines of code in vb.net is working fine.
Code:
using System;
using System.Data;
using System.Data.SqlClient;
public static DataSet returndataset(string connectionstring, string str)
{
SqlConnection con = new SqlConnection(connectionstring);
DataSet ds = new DataSet();
SqlCommand cmd = new SqlCommand(str, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds);
return ds;
}
Kindly help me to solve this problem.And suggest some links to study C#.
Thanks in advance
-
Apr 11th, 2007, 04:44 AM
#2
Re: [02/03] Stuck in C# code
Perhaps the C# forum would be a more appropriate place for this thread. I suggest that you PM a mod and ask them to move it.
The reason for your error is that you must declare a type before you can declare a member. You've declared a method, which cannot exist on its own. It must be within a type declaration. That's why you're told that it is expecting one of those list of things, all of which are types.
-
Apr 11th, 2007, 09:56 AM
#3
Re: [02/03] Stuck in C# code
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 11th, 2007, 10:10 AM
#4
Re: [02/03] Stuck in C# code
same lines of code in vb.net is working fine.
I doubt it.
To add a class to your project, right click your project, add new, and choose class. It will come 'pre-coded' like a skeleton. In the closet.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|