Click here to Skip to main content
15,900,378 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I am using vs2010,asp.net and sql server 2008.

how to use sql select statement in java script using sql server 2008.

how to get datatable form above select statement.

help will be appreciate .......

Regards
Mukesh
Posted
Comments
Zafar Sultan 17-Jun-13 6:02am    
What exactly you want to achieve? Since javascript is a client side scripting language it can not directly call select statement using sql server. If you will tell us what is your requirement, we might help you in an alternate way. BTW, have you written some code for it?
mukesh_panth 17-Jun-13 7:20am    
i have an array and my requirement is to use it datatable so that i can fire query on datatable..

Please refer following thread:
sql query using javascript[^]
 
Share this answer
 
Use simple page method ................

use sever side code........in .aspx page

using System;
using System.Web.Services;

namespace GoogleChartASPDEMO
{
public partial class _Default : System.Web.UI.Page
{

[WebMethod]
public static string PerformDatabaseQuery(string strpass)
{

SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
SqlCommand cmd = con.CreateCommand();
con.Open();
cmd.CommandText = " SELECT * FROM Shipments_Data ";

cmd.CommandType = CommandType.Text;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
DataTable Dt = new DataTable();
Dt = ds.Tables[0];
con.Close();
}
}
}


client side code .................


$(document).ready(function () {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
data: "{strpass:'" + pass_value + "'}",
url: "Default.aspx/PerformDatabaseQuery",
dataType: "json",
success: function (data) {
alert("success")
},
error: function (result) {
alert("Error");
}


use this code..... it is useful ....
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900