.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Cannot Fetch Data via SQLFetch Function (ODBC Programming)

Posted By:      Posted Date: October 17, 2010    Points: 0   Category :Sql Server

Hello Everyone

I'm c# developer but i want use c++ for the future times.  I'm newly in ODBC Native programming. I wrote this code and compiled successful but i can't get customerIds. Because i get an error its "[Microsoft][ODBC Driver Manager] Invalid descriptor index" here is my code

#include <Windows.h>

#include <sql.h>

#include <sqltypes.h>

#include <sqlext.h>

#include <stdio.h>

int main()






	SQLWCHAR	*szDns = L"Driver={SQL Server};Server=.\\SQLEXPRESS;Database=TestForQt;Trusted_Connection=Yes;";


	int			columnValue;

	rc = SQLAllocEnv(&hEnv);


	rc = SQLAllocConnect(hEnv, &hDbc);


	rc = SQLAllocStmt(hDbc, &hStm);

	rc = SQLExecDirect(hStm, L"SELECT customerId FROM customer", SQL_NTS);

	while(SQLFetch(hStm) == SQL_SUCCESS)


View Complete Post

More Related Resource Links

ERROR [S1000] [Microsoft][ODBC Visual FoxPro Driver]Function name is missing ).


I Am Continiously Getting Error For Following Line Of Code, It Work  Fine In Other Database

Am I Doing Any Mistake

if (sh3itno != "" && dpsh3no != "")
                string queryy = "SELECT [CHEQNO] FROM [SH3MAST] WHERE (([CHEQDATE] = " + chqdate + ") AND ([FAVOUR] = " + favour + ") AND ([CHQTYPE] = " + ctype + ") AND ([TRSTN] = " + trstn + ") AND ([TRBANK] = " + trbank + ") AND ([SH3ITNO] = " + sh3itno + ") AND ([DPSH3NO] = " + dpsh3no + "))";
                OdbcCommand cmd3 = new OdbcCommand(queryy, connen1);
                string chqno =cmd3.ExecuteScalar().ToString(); (Here Iam Getting Error)
                tbl.Rows[i]["cheque no"] = chqno;
Stack Trace: 

[OdbcException (0x80131937): ERROR [S1000] [Microsoft][ODBC Visual FoxPro Driver]Function name is missing ).]
   System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode) +39
   System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, Strin

How to fetch data from textbox dynamically in a gridview

How to fetch data from textbox inside a gridview

How to insert values into my table the data is coming from inline table valued function

Hi all,   i have table oi want insert values into my table the data is coming from inline table valued function how i can use the inline table valued function to insert datainto my table i have inline function which out puts 3 collumns of data how i can insert this data into my table i have the insert statment like below insert into tablename(c1,c2,c3,c4,c5) select ('abc',....................,'xyz') how i can use the out put put of my inline function to  to insert data into my columns c2,c3,c4. please help me out Thanks & Regards Sunil Yoganna

Data Binding a DataGrid to a list fetch the same data multiple times

Hi, I'm using DataGrid to show data through data binding. My data are provided in a list. The setup I have is the following: DataGrid "binded" to the default view of my list that implement IList<T> and IList interfaces (MyList<T> : IList<T>, IList, INotifyCollectionChanged)             CollectionViewSource.GetDefaultView(_myList);             // Set the data context             DataContext = view; T: is here my 'business object' that hold the data, called 'MyRow'. Then the columns of the DataGrid are bound to public properties of 'MyRow' object. MyRow class has a public property of type 'object' (public object data[int index]) and first column of datagrid is bound to myRow.data[0], second column is bound to myRow.data[1] and so on.   When the datagrid is displayed, databinding kick in and my data are showed in the control. The issue I'm having is that data fetching is very repetitive even for the same rows. For example for a datagrid with 20 visible rows, the first row is fetched multiple times even if the datagrid is not resized or moved. I put break point inside my list (MyList<T> into This[T] property (public T this[int index]) and i got multiple hits into the property for the same index. Fetc

Bug in ODBC SQL Server driver (SQLFetch hangs)

I have come across a bug in the ODBC driver for SQL Server when working against SQL Server 2008 64-bit with TDE where tables contain text-datatypes. We concluded that it is a bug after testing a simple SQL query using Microsoft ODBC test tool (odbcte.exe) and the workaround for us was to start using the "SQL Native Client 10" instead. However I would like to share this information if someone else come across this problem. Below I will describe the problem in more detail. The table has three columns with text datatypes and we use a simple select query against this table to return about 10 rows of data but SQLFetch hangs before all data is returned. It is unfortunately very difficult to reproduce the errror since even a very small change will change the behaviour. If we for example add or remove a column to the select statement then the problem will dissappear, if we call SQLBindCol before instead of after SQLExecute (or the other way around) the problem will dissapear, if we change the WHERE-clause to fetch a different set of rows the problems will dissapear. We have seen the problem though with a number of different SQL queries so it is reproducable.

fetch data from cursor(what wrong?)

hi there i have a SP that send mailbut in the cursor does not appears no one record, i written PRINT'-------' , and it seems no recordwhere is wrong here?the query returns 200 records here, but not in cursoralter PROCEDURE [dbo].MAIL (@date date) AS BEGIN declare @MonthlyTimeInterval int declare @WorkingDaysBeforeOpen int declare @WorkingDaysBeforeClose int ----valorizzazione parametri MAIL--------- select @MonthlyTimeInterval=MonthlyTimeInterval, @WorkingDaysBeforeOpen=WorkingDaysBeforeOpen, @WorkingDaysBeforeClose=WorkingDaysBeforeClose FROM ParameterData --------market in apertura------------- DECLARE @getMktOpen CURSOR declare @PeriodEND date declare @PeriodStart date declare @Market Varchar(300) declare @Status bit declare @MarketID int DECLARE @MarketPeriodID INT SET @getMktOpen = CURSOR FOR SELECT MAX(Period.[Desc]) AS PeriodEND, MIN(Period.[Desc]) AS PeriodStart, Market.[Desc] AS Market, MarketPeriod.Status, Market.MarketID, MarketPeriod.MarketPeriodID FROM MarketPeriod INNER JOIN Period ON MarketPeriod.PeriodID = Period.PeriodID INNER JOIN Market ON MarketPeriod.MarketID = Market.MarketID GROUP BY Market.[Desc], MarketPeriod.Status, Market.MarketID, MarketPeriod.MarketPeriodID -- HAVING (MarketPeriod.Status = 0) -- AND (MIN(Period.[Desc]) = CONVERT(CHAR(11),@date,111) ) OPE

"Logon failed. Details: IM002:[Microsoft][ODBC Driver Manager] Data source name not found and no def

When i attempt to fill my Crystal Report -named limitler.rpt and it is under the sub-folder Oraburslar of my project -, i get the following error; "ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified. Error in File C:\DOCUME~1\KEMAL~1.ESM\LOCALS~1\Temp\limitler {148B6FE6-D5BE-4BC3-A13A-47CCCB79D78B}.rpt: Unable to connect: incorrect log on parameters." How can i handle this pro? Thanks in advance... Here is how i connect to database to fill the Crystal Report:string database = ConfigurationManager.AppSettings["Database"].ToString(); string password = ConfigurationManager.AppSettings["Password"].ToString();string username = ConfigurationManager.AppSettings["Username"].ToString(); string server = ConfigurationManager.AppSettings["Server"].ToString();ReportDocument report = new ReportDocument();report.Load(Server.MapPath("~/Oraburslar/limitler.rpt")); report.SetDatabaseLogon(username, password); CrystalReportViewer1.ReportSource = report; CrystalReportViewer1.BackColor = System.Drawing.Color.White;

Error: "Select statements included within a function cannot return data to a client"

hi all, Not sure if there is an easier way to do this but this is my first ever Function I created so far. I am getting the error: "Select statements included within a function cannot return data to a client" All I am trying to do is ...if the date is NOT passed then apply NULL as the default value and run the SELECT statement. If the date IS NOT null then run a different SELECT statement. CREATE FUNCTION [SchemaTest].[fn_Test] ( @instance as uniqueidentifier ,@date as datetime = null ) RETURNS varchar(8000) AS BEGIN If (@date is null) --@date = null ?? Begin Select * From Uds.RealtimeLogging Where instanceID = @instance End Else Begin Select * From Uds.RealtimeLogging Where instanceID = @instance and [timeStamp] > @date End Return @stepIds END Thank you!JCD

Infopath 2007: Cant we fetch data from a list or form library without using a Query to the data conn

I am trying to fetch data from a form library and a list (both secondary data sources). But cant do it without using a rule (Query using a data connection). However when I use the 'Refresh' control on the form it brings the value. I find it quite weird, as the connections are made properly and logically speaking all the data connetions should fetch dynamic data once the form opens or loads. Cant we do it without using a (data query) rule? Update: I am using a web based infopath forms, while using the same form on client its working fine. Why is that?

How Fetch Data from HTML tags

Aslam o alaikum to allI am working in asp.net and vb.net i want to get data from <p>Dta to get in vb code</p> this and from a table like<table><tr><td>ID</td><td>Name</td><td>1</td><td>Saleem</td></tr><table>please help me thanks and best regards

Cannot access a SQL data base since a .net application usin ODBC and/or one by one instructions


At the time when we try to access a database the followin message is showed: ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]'Mid' is not a recognized function name.

I created an ODBC and when the database connection is tested there is no problem, the problem is when I try to access since the program.

Fetch data from one list and populate another list


How to fetch the details from one list & show it in an another list in Sharepoint 2010.


List #1 : Total Project/Resource List

   Resources       Projects
         Resource1 Project1,project2
  REsource2 Project1,project3

List #2 : Resources Per project


How to fetch details from List1 based on projects (Projects (Multiline text) are comma seperted data)


[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified


trying to install sql server2005 on a windows 2003 server box.

getting msg below at the sql server .  i looked at other posts on trying to uninstall  SQL Native Access Client and norton antivirus.  i could never find the snac on the add - remove programs and this server does not have a virus protection program yet.

here's the history of the installs on the server:

wanted to test a 2005 upgrade so:

  1) installed sql server 2000 then sp4 then restored some databases to it - all OK

  2) tried to upgrade to sql 2005 but ran into problems and left it at that.

had a disk drive crash on the d drive so lost the installs but not the operating system

when the drive was replaced, left alone for a while

then wanted to test a straight 2005 install

  1) removed the broken 2005 attempt

  2) removed the 2000

  3) installed 2005 and got the error on the subject line:

TITLE: Microsoft SQL Server 2005 Setup

SQL Server Setup could not connect to the database service for server configuration. The error was: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified Refer to server error logs and setup logs for more information. For details on how to view setup logs, see "How to View Setup Log Files" in S

Fetch data from JDEdwards


Dear Friends,

I want to fetch data from JDEdwards and put it in Microsoft Sql Server 2005, how it is possible ?, please describe it.



How to fetch data from nested gridview


Hi, Please guide me how to fetch data from Nested gridview checkbox on Click button event which is present outside the gridview. I did try by creating an object of child gridview on button1_click but cannot fill the value from Gridview2 into my int i. Below mentioned is the Code i am using. The database I am using is Oracle.

 ==== Code =====

 protected void Button1_Click(object sender, EventArgs e)


OracleConnection con = new OracleConnection();

        con.ConnectionString = ConfigurationSettings.AppSettings["oracle"];

        //int RowIndex = Convert.ToInt32(e.CommandArgument);


        //GridView subGrid = (GridView)GridView1.Rows[RowIndex].FindControl("GridView2");


        //GridView subGrid = (GridView)GridView1.FindControl("GridView2");

        int i = 0;

        GridView subGrid =((GridView)GridView1.Rows[i].FindControl("GridView2"));


Status of Accessing Nested Objects in Data Source of Local Report Does Not Function


We recently upgraded out platform to .NET 4.  We are also using Microsoft Reporting dlls.  Unfortunately, we found that the upgrade broke all of our reports.  Researching the cause, we found this article:


It seems that this issue has been open for some time now and I have not seen a good workaround (except for the shim class which is not really feasible for us).  Can I please get a status update for this?  Is there some other type of resolution?

Thank you,

Benjamin Strum 

Ben Strum

saving the data and then deleting the data using javascript function in anchor tag


Hello guys,

What I am trying to do is I have a dataview webpart. In that I have a field called comments which I made it as a text box. I have provided them a option delete. So user before deleting the item, he has to enter the comments and delete. The comments which I enter has to save in list. then I wrote one event handler which is for item deleting, which will copy values to other location deletes the list item.

The problem is the comments are getting saved to list before deleting. The javascript function for delete in anchor tag is 

<a href="javascript: if(DeleteItemConfirmation()) {ddwrt:GenFireServerEvent(concat('_cancel;__delete={',$KeyField,'=',$KeyValue,'};__commit;__redirect=''};

so I have to save the comments before it gets deleted. So I am trying to insert {ddwrt:GenFireServerEvent('__commit;'};this in some place anchor tag before delete, but its getting saved, but not deleting.

Hope you guys understand what I am talking. So can I do something such that it saves the comments and go for delete...

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend