Questions tagged [sqlcommand]

Represents a Transact-SQL statement or stored procedure to execute against a SQL Server database which is used in Microsoft .NET.

SqlCommand is a class in the .NET Framework whose instances represent a SQL statement to later be executed against a SQL Server database.

General syntax:

SqlCommand is instantiated with a query string and a connection. In C#:

SqlCommand cmd = new SqlCommand("select CategoryName from Categories", con);

Reference

SqlCommand on MSDN

919 questions
-4
votes
2 answers

c# sql command premeter crashing

Can someone please tell me what is wrong with the code? The data source is good and it is showing me the same mistake each time: using System; using System.Collections.Generic; using System.Linq; using System.Text; using…
-4
votes
3 answers

how to retrieve data from database in combobox c#

I wrote this code but I do not know why this line gives error! String sname = dr.GetString ("name"); My code: SqlConnection cn = new SqlConnection( "Data Source=.;Initial Catalog=logindb;Integrated Security=True"); string query1 = "select *…
user3674314
  • 17
  • 1
  • 4
-8
votes
3 answers

Getting Error: Not all code paths a value

public bool loginpro(string loginas, string dept, string usnm, string pass) { try { string qrstr; qrstr = "select * from login where loginas=='" + loginas + "',dept=='" + dept + "',usnm=='" + usnm + "',pass=='" + pass + "'"; …
Swaroop
  • 3
  • 2
-10
votes
1 answer

How do I solve this compile error?

I'm getting this compile error message. How do I solve it? Error 28 'WindowsFormsApplication1.SqlCommand' does not contain a definition for 'Parameters' and no extension method 'Parameters' accepting a first argument of type…
1 2 3
61
62