Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;

using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data.SqlTypes;

namespace EDAIF
{
    public partial class Loanmaster : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //Page Load Begins
            if (!IsPostBack)
            {
                try
                {
                    SqlConnection connect = new SqlConnection();
                    connect.ConnectionString = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
                    connect.Open();
                    SqlDataAdapter da = new SqlDataAdapter("SELECT *  ,
                                                            BRANCH.BRN_NAME,
                                                            TANK.TANK_NAME,
                                                            SECTORS.[SECTOR NAME]
                                                            FROM TANKMASTER 
	                                                            LEFT JOIN BRANCH ON
		                                                            BRANCH.BRN_NO=LOANMASTER.BRN_nO
	                                                            LEFT JOIN SECTORS ON
		                                                            SECTORS.[SECTOR NUMBER]=LOANMASTER.SEC_NO	
	                                                            LEFT JOIN TANK ON
		                                                             TANK.TANK_CODE=LOANMASTER.TANK_NO1 
                                                                 AND TANK.TANK_CODE=LOANMASTER.TANK_NO2
                                                                 AND TANK.TANK_CODE=LOANMASTER.TANK_NO3", connect);

                    DataSet ds = new DataSet();
                    da.Fill(ds, "TANK");

Error in the select statement please assist. new in c#


[Edit member="Tadit"]
Added pre tags.
[/Edit]
Posted
v2
Comments
ArunRajendra 3-Jun-14 6:54am    
The query is fine. What error are you getting?
Bh@gyesh 3-Jun-14 6:58am    
I think you have not included "LOANMASTER" table in query. Add it.
Bhushan Patki 3-Jun-14 7:04am    
You have to first execute these query in sql server.
what the error you are getting?
Tell us the exact Error details.

1 solution

1.First you should test and refine your SQL string in "SQL Server Management Studio";

2.Then you could use it in C# code, and you C# code seems to be OK.

PS: You should give the original error message in you post, in order to can give you more advises.
 
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