I was wondering if there was a compilation of any known differences in the accepted SQL syntax structure between running the query directly in SQL Management Studio and creating the SQL query as a string in the .net application and sending it through SQLCommand and Connection? I was going to ask about a specific problem that I had with one specific query, but as it turned out, I am having several problems with multiple queries. I basically take a set of queries written by someone else and embed them in the .Net parts that I implement, but I believe that I need to configure most of the queries (for example, Table1.Column1 does not work, just Column1 works fine)
I was wondering if there are problems that I am facing, known differences between the two environments, or is the problem related to database / schema / query structure problems?
EDIT EXAMPLE:
The following 4 queries work in SQL Management Studio but are not transferred to the SQL connection in the .net web part. By not working, I mean that the web part will not load on the asp page (this is actually a SharePoint page), and, as I was told by SharePoint, this creates a problem. I am not sure about the correct sharepoint logs to look at them ... (PAY ATTENTION. I know that these queries do not make sense, for example, the meaninglessness of the FROM clause, but they are debug queries that I played with try to identify problems)
5- SQL Management Studio, - .NET, , .
//
SELECT DISTINCT
'2011' AS Yr, '01' AS PerNbr, 1 AS Amount
FROM Submissions AS s INNER JOIN
JurisdictionalData AS j ON re_KeyTbl = Keytbl AND s.jurisdiction <> REPLACE(j.JurisdictionTxt, 'Jurisdiction', '')
//
SELECT DISTINCT
'2011' AS Yr, '01' AS PerNbr, 1 AS Amount
FROM Submissions AS s INNER JOIN
JurisdictionalData AS j ON j.re_KeyTbl = s.Keytbl AND s.jurisdiction NOT IN (REPLACE(j.JurisdictionTxt, 'Jurisdiction', ''))
//
SELECT DISTINCT
'2011' AS Yr, '01' AS PerNbr, 1 AS Amount
FROM Submissions AS s INNER JOIN
JurisdictionalData AS j ON j.re_KeyTbl = s.Keytbl AND s.jurisdiction NOT IN (j.JurisdictionTxt)
//
SELECT DISTINCT
'2011' AS Yr, '01' AS PerNbr, 1 AS Amount
FROM Submissions AS s INNER JOIN
JurisdictionalData AS j ON j.re_KeyTbl = s.Keytbl AND s.jurisdiction <> j.JurisdictionTxt
//
SELECT DISTINCT
'2011' AS Yr, '01' AS PerNbr, 1 AS Amount
FROM Submissions AS s INNER JOIN
JurisdictionalData AS j ON j.re_KeyTbl = s.Keytbl AND s.jurisdiction = j.JurisdictionTxt
# ( ):
:
//sql db connection string
private string _cnString =
"Server=_server;" +
"Database=_db;" +
"User ID=_user;" +
"Password=_password;" +
"Trusted_Connection=False";
//sql query
private string query = "SELECT DISTINCT " +
"'2011' AS Yr, '01' AS PerNbr, 1 AS Amount " +
"Submissions AS s INNER JOIN " +
"JurisdictionalData AS j ON j.re_KeyTbl = s.Keytbl AND s.jurisdiction = j.JurisdictionTxt ";
CreateChildControls:
SqlConnection sqlConn = new SqlConnection(_cnString);
//run SQL query and store results in a dataset
SqlCommand sqlCmd = new SqlCommand(query, sqlConn);
SqlDataAdapter adp = new SqlDataAdapter(sqlCmd);
DataSet ds = new DataSet();
adp.Fill(ds);