answersLogoWhite

0

at the top

using System.Data.SqlClient;

in the main body (perhaps a click event)

//creates a connection object with a given connection string

SqlDataConnection conn = New SqlDataConnection("connection String");

//creates a command object with the sql and the connection it is to use

SqlCommand cmd = new SqlCommand("SQL String",conn);

//create a data reader to store the data retrieved from the database

SqlDataReader rdr;

//open the connection

conn.Open();

//executes the sql and stores the result in the rdr (Use if there is more than one //cell retrieved from database e.g all records where a value is greater than 0

rdr = cmd.ExecuteReader();

//if there is only one cell retrieved such as only the orderid for a specific order then //use:

variable = cmd.ExecuteScalar();

//then do something with the data WARNING: the connection MUST be open to use the data reader but not with the scalar method

//close the connection

conn.Close();

Hope this helps!

steve

User Avatar

Wiki User

14y ago

What else can I help you with?

Continue Learning about Engineering

Do you need sql and c plus plus to code in them in Visual Studio?

Connect to a SQL Server, query with Transact-SQL (T-SQL), and view the results with the mssql plugin for Visual Studio Code. The SQL Database projects extension for VS Code comes with the mssql extension, which supports SQL projects on Windows, macOS, and Linux. To learn more about data science please visit- Learnbay.co


How do you convert java data to SQL data?

kill urself


What is mblob?

A BLOB is a binary large object which is a chunk of data for a database. An mblob is a medium blob used in php code for an SQL databse.


How do you avoid duplicate data entry in aspnet with sql?

We can done with the help of Primary concept in Sql Server.


A vulnerability of web based aplication?

1) Reliance on JavaScript for data validation. JavaScript is a cool tool for checking user input to make sure it is valid. But people can disable or just plain bypass JavaScript. If the server assumes that the data is OK because it was validated by JavaScript, then the server is making a false assumption. 2) SQL injection. If you take user input and splice it together with other strings to form a SQL query, then your SQL query is vulnerable. There are ways to inject valid SQL into an input field that makes the SQL query do things the programmer didn't intend. 3) Cross Site Scripting (XSS). Your site allows people to input data that is displayed to other users. If the user can enter HTML code, and you pass it along to other users unmodified, their browsers will treat it as HTML code. If that HTML code happens to include some JavaScript, then you are essentially running code inside someone elses browser. Bad stuff can happen from there. There are others, but those are probably the top 3. Google for (lots) more information.

Related Questions

How do you store and retrieve images from ms access or MySQL database using JSP source code required?

Retrieve sql data you may with the help of programming way. You need to software working with sql databases of any version SQL Server. I would recommend you to try tool below.


What is a query language that allows users to manage update and retrieve data?

SQL


What is the SQL data base material used for?

The SQL data base is programming language used to manipulate and retrieve data. Included in the language are elements such as data insert, query, update and delete.


What is the name of a statement written to retrieve specific data from a table?

The name of a statement written to retrieve specific data from a table is a SQL SELECT statement.


Which one of the following is the most efficient way to retrieve data from an MS SQL database?

SqlDataReader


How do you retrieve data from table in sql by selecting month?

select * from "table-name" where month="required month";


What is the command to retrieve deleted data from any table in SQL?

rollback command can retrieve deleted data from a table, provided commit has not been performed after deleting the data. both rollback and commit are transaction control statements.


Sql command to retrive all data froma table?

The SQL command that can be used to retrieve all data from a table is the SELECT Ex: Let us say we have a table called employee_master which contains 3 columns emp_name, emp_number, date_of_joining you can retrieve all the data by using the below command SELECT * FROM employee_master or SELECT emp_name, emp_number, date_of_joining FROM employee_master


How do you retrieve data from an SQL database based on the values selected from combo box using jsp?

Try to repair sql database owing to utility below. Software is able to restore sql databases any version of MS SQL Server.


What is the function of Microsoft SQL?

SQL is a relational database management system. The very first function of this software is to keep the data safe and retrieve it When it is asked by other software applications.


What is the SQL Server Express used for?

The SQL Server Express is used to store and retrieve data when requested by other software operations that are running within the same computer or network.


What database objects allows you to search for and retrieve data?

SQL queries allow you to search for and retrieve data from a database. By writing SELECT statements with specific criteria, you can search for information in tables and retrieve the results based on your query.