Showing posts with label writing. Show all posts
Showing posts with label writing. Show all posts

Monday, March 26, 2012

odbc datagrida

Good Day,
I got a table with company details.I am using ODBC to conect to it.

I am writing a windows form application in C# 2005 express edition.The task is to search companies. my code is as below.


OdbcCommand cmd = new OdbcCommand("use company", MyConnection);

cmd.CommandText = "SELECT * FROM employee WHERE Name = ?;"; /****line 3*****/
cmd.Parameters.Add("@.Name", OdbcType.VarChar, 30);
cmd.Parameters["@.Name"].Value = textBox1.Text;
cmd.ExecuteNonQuery();

OdbcDataAdapter datadapter = new OdbcDataAdapter(cmd.CommandText, MyConnection);
DataSet dataset = new DataSet();
datadapter.Fill(dataset,"employee"); /**error line***/

dataGridView1.DataMember="employee";
dataGridView1.DataSource=dataset;


The

above code compiles cleanly but when you run it,it gives a error. the

error statemnet is as below and the line giving error is show above in

coment.


ERROR [07002] [MySQL][ODBC 3.51 Driver][mysqld-5.0.27-community-nt]SQLBindParameter not used for all parameters


When line 3 is replaced by cmd.CommandText = "SELECT * FROM employee;"; the program works. fine.

I can view all employees only.BUT not a specific employee.
the problem looks complex.If some-one can help me out,it would be much appreciated.

Thanx
Rahul SK

msn add:ar_kul@.hotmail.comDo you sure that 'Name' field is exists in this table?

odbc datagrida

Good Day,
I got a table with company details.I am using ODBC to conect to it.

I am writing a windows form application in C# 2005 express edition.The task is to search companies. my code is as below.


OdbcCommand cmd = new OdbcCommand("use company", MyConnection);

cmd.CommandText = "SELECT * FROM employee WHERE Name = ?;"; /****line 3*****/
cmd.Parameters.Add("@.Name", OdbcType.VarChar, 30);
cmd.Parameters["@.Name"].Value = textBox1.Text;
cmd.ExecuteNonQuery();

OdbcDataAdapter datadapter = new OdbcDataAdapter(cmd.CommandText, MyConnection);
DataSet dataset = new DataSet();
datadapter.Fill(dataset,"employee"); /**error line***/

dataGridView1.DataMember="employee";
dataGridView1.DataSource=dataset;


The above code compiles cleanly but when you run it,it gives a error. the error statemnet is as below and the line giving error is show above in coment.

ERROR [07002] [MySQL][ODBC 3.51 Driver][mysqld-5.0.27-community-nt]SQLBindParameter not used for all parameters


When line 3 is replaced by cmd.CommandText = "SELECT * FROM employee;"; the program works. fine.

I can view all employees only.BUT not a specific employee.
the problem looks complex.If some-one can help me out,it would be much appreciated.

Thanx
Rahul SK

msn add:ar_kul@.hotmail.comDo you sure that 'Name' field is exists in this table?
sql

Friday, March 23, 2012

ODBC connection to SQL server DB

I'm writing a VB app to read and write data to an SQL server database.

I have successfully done so using ADO however I now need to do it using ODBC.

I have set up the appropriate DSN and have no trouble reading data from the database but when I try to write to it I get a message indicating that the database is open for read only access.

I'm no sure whether the restriction is and the VB, ODBC, or database level.

Here's the code which opens the database and recordset.

Set dbsWarehouseServer = OpenDatabase(ODBCDSName, _
dbDriverNoPrompt, False, _
"DSN=" & ODBCDSName)

Set rstRailSet = dbsWarehouseServer.OpenRecordset("Select Store_date, SLN From " & TBName & " where Rail_set_ID = '" & RailID & "'", dbOpenDynaset)

Any help is greatly appreciated.What if you changed this to your statement:

Set rstRailSet = dbsWarehouseServer.OpenRecordset("Select Store_date, SLN From " & TBName & " where Rail_set_ID = '" & RailID & "'", adOpenDynamic, adLockOptimistic)

Just a thought.|||Thank's for the idea. No luck though.
Not sure but maybe the restriction is at the ODBC or SQL level although I have no trouble with ADO so I suspect ODBC.|||Just wondering...is RailID an integer value?

If so, wouldn't you use:

Set rstRailSet = dbsWarehouseServer.OpenRecordset("Select Store_date, SLN From " & TBName & " where Rail_set_ID = " & RailID & "", dbOpenDynaset)

instead of:

Set rstRailSet = dbsWarehouseServer.OpenRecordset("Select Store_date, SLN From " & TBName & " where Rail_set_ID = '" & RailID & "'", dbOpenDynaset)

Again, just another thought but probably not on the right path.|||When you create the ODBC connection on your pc, which username are you using, I believe that is not 'sa'. You must be using another username created in the SQL server user login.
Check the right for that username you have created. Does it have the right to write to that specify database. If you put it to db owner, you can do anything with that database.

Monday, March 19, 2012

ODBC API Bulk Update Question

Hi all,
Quick question - I'm writing a program that uses the ODBC API to bulk load
data into SQL Server. I have nailed the Bulk Insert, no problems. Now I
need to use Update By Bookmark, but am having trouble. Does anyone know
where I can find ODBC Update By Bookmark samples? The SQL BulkOperations
sample application on MSDN is inadequate, incomplete and buggy.
ThanksNever mind, figured it out, works great.
"Michael C" wrote:
> Hi all,
> Quick question - I'm writing a program that uses the ODBC API to bulk load
> data into SQL Server. I have nailed the Bulk Insert, no problems. Now I
> need to use Update By Bookmark, but am having trouble. Does anyone know
> where I can find ODBC Update By Bookmark samples? The SQL BulkOperations
> sample application on MSDN is inadequate, incomplete and buggy.
> Thanks

ODBC and XML

Hi all,
I'm writing an app to export my ODBC connection information to XML format.
There is already a standard File .DSN format, but was wondering if there's
already an XML DTD or XML Schema for DSN's out there. I definitely don't
want to reinvent the wheel, and if I'm able to export my info in a format
that would (presumably) be compatible with other applications in the future,
so much the better.
Thanks,
Michael C.I know that Microsoft has not defined anything in this area, and I
haven't heard of any other ISVs doing this.
Brannon
Michael C wrote:

> Hi all,
> I'm writing an app to export my ODBC connection information to XML format.
> There is already a standard File .DSN format, but was wondering if there's
> already an XML DTD or XML Schema for DSN's out there. I definitely don't
> want to reinvent the wheel, and if I'm able to export my info in a format
> that would (presumably) be compatible with other applications in the futur
e,
> so much the better.
> Thanks,
> Michael C.
>

ODBC and XML

Hi all,
I'm writing an app to export my ODBC connection information to XML format.
There is already a standard File .DSN format, but was wondering if there's
already an XML DTD or XML Schema for DSN's out there. I definitely don't
want to reinvent the wheel, and if I'm able to export my info in a format
that would (presumably) be compatible with other applications in the future,
so much the better.
Thanks,
Michael C.
I know that Microsoft has not defined anything in this area, and I
haven't heard of any other ISVs doing this.
Brannon
Michael C wrote:

> Hi all,
> I'm writing an app to export my ODBC connection information to XML format.
> There is already a standard File .DSN format, but was wondering if there's
> already an XML DTD or XML Schema for DSN's out there. I definitely don't
> want to reinvent the wheel, and if I'm able to export my info in a format
> that would (presumably) be compatible with other applications in the future,
> so much the better.
> Thanks,
> Michael C.
>

Wednesday, March 7, 2012

obtaining return values from DBCC INDEXDEFRAG in a sp

Hi All,
I am writing a stored procedure that performs a DBCC INDEXDEFRAG on a number
of indexes.
I wish to then manipulate the values from the result set (Pages Scanned,
Pages Moved, Pages Removed). However I cannot seem to find a way to do this
Can anyone help please?
Thanks in advance
DanCreate a table with the same structure as the DBCC returns and then use below technique:
INSERT theTable
EXEC('DBCC...')
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Dan" <dan.parker@._nospam_pro-bel.com> wrote in message
news:uJ2XdA5qEHA.4044@.TK2MSFTNGP09.phx.gbl...
> Hi All,
> I am writing a stored procedure that performs a DBCC INDEXDEFRAG on a number of indexes.
> I wish to then manipulate the values from the result set (Pages Scanned, Pages Moved, Pages
> Removed). However I cannot seem to find a way to do this
> Can anyone help please?
> Thanks in advance
> Dan
>|||You can't do that as the insert/exec creates a user transaction and
INDEXDEFRAG cannot run inside a user transaction. There's no way to capture
the results from INDEXDEFRAG except using an external text file.
Dan - what do you want to do with the values, out of interest?
Regards
--
Paul Randal
Dev Lead, Microsoft SQL Server Storage Engine
This posting is provided "AS IS" with no warranties, and confers no rights.
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:uZVSYG5qEHA.2732@.TK2MSFTNGP09.phx.gbl...
> Create a table with the same structure as the DBCC returns and then use
below technique:
> INSERT theTable
> EXEC('DBCC...')
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Dan" <dan.parker@._nospam_pro-bel.com> wrote in message
> news:uJ2XdA5qEHA.4044@.TK2MSFTNGP09.phx.gbl...
> > Hi All,
> >
> > I am writing a stored procedure that performs a DBCC INDEXDEFRAG on a
number of indexes.
> >
> > I wish to then manipulate the values from the result set (Pages Scanned,
Pages Moved, Pages
> > Removed). However I cannot seem to find a way to do this
> >
> > Can anyone help please?
> >
> > Thanks in advance
> >
> > Dan
> >
>|||Ah, thanks Paul. I didn't consider the transaction aspect of it...
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Paul S Randal [MS]" <prandal@.online.microsoft.com> wrote in message
news:%23GZ7H38qEHA.708@.tk2msftngp13.phx.gbl...
> You can't do that as the insert/exec creates a user transaction and
> INDEXDEFRAG cannot run inside a user transaction. There's no way to capture
> the results from INDEXDEFRAG except using an external text file.
> Dan - what do you want to do with the values, out of interest?
> Regards
> --
> Paul Randal
> Dev Lead, Microsoft SQL Server Storage Engine
> This posting is provided "AS IS" with no warranties, and confers no rights.
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
> message news:uZVSYG5qEHA.2732@.TK2MSFTNGP09.phx.gbl...
>> Create a table with the same structure as the DBCC returns and then use
> below technique:
>> INSERT theTable
>> EXEC('DBCC...')
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://www.solidqualitylearning.com/
>>
>> "Dan" <dan.parker@._nospam_pro-bel.com> wrote in message
>> news:uJ2XdA5qEHA.4044@.TK2MSFTNGP09.phx.gbl...
>> > Hi All,
>> >
>> > I am writing a stored procedure that performs a DBCC INDEXDEFRAG on a
> number of indexes.
>> >
>> > I wish to then manipulate the values from the result set (Pages Scanned,
> Pages Moved, Pages
>> > Removed). However I cannot seem to find a way to do this
>> >
>> > Can anyone help please?
>> >
>> > Thanks in advance
>> >
>> > Dan
>> >
>>
>|||Hi Paul,
I want to put them into a "User Friendly" report, that basically lists the
time, index defragged and the pages scanned, moved, etc.
Regards
Dan
"Paul S Randal [MS]" <prandal@.online.microsoft.com> wrote in message
news:%23GZ7H38qEHA.708@.tk2msftngp13.phx.gbl...
> You can't do that as the insert/exec creates a user transaction and
> INDEXDEFRAG cannot run inside a user transaction. There's no way to
> capture
> the results from INDEXDEFRAG except using an external text file.
> Dan - what do you want to do with the values, out of interest?
> Regards
> --
> Paul Randal
> Dev Lead, Microsoft SQL Server Storage Engine
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote
> in
> message news:uZVSYG5qEHA.2732@.TK2MSFTNGP09.phx.gbl...
>> Create a table with the same structure as the DBCC returns and then use
> below technique:
>> INSERT theTable
>> EXEC('DBCC...')
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://www.solidqualitylearning.com/
>>
>> "Dan" <dan.parker@._nospam_pro-bel.com> wrote in message
>> news:uJ2XdA5qEHA.4044@.TK2MSFTNGP09.phx.gbl...
>> > Hi All,
>> >
>> > I am writing a stored procedure that performs a DBCC INDEXDEFRAG on a
> number of indexes.
>> >
>> > I wish to then manipulate the values from the result set (Pages
>> > Scanned,
> Pages Moved, Pages
>> > Removed). However I cannot seem to find a way to do this
>> >
>> > Can anyone help please?
>> >
>> > Thanks in advance
>> >
>> > Dan
>> >
>>
>|||I'm afraid the only way to do it is to output the results to a flat file and
then post-process.
Regards
--
Paul Randal
Dev Lead, Microsoft SQL Server Storage Engine
This posting is provided "AS IS" with no warranties, and confers no rights.
"Dan" <dan.parker@._nospam_pro-bel.com> wrote in message
news:uE0WCTFrEHA.3428@.TK2MSFTNGP11.phx.gbl...
> Hi Paul,
> I want to put them into a "User Friendly" report, that basically lists the
> time, index defragged and the pages scanned, moved, etc.
> Regards
> Dan
>
> "Paul S Randal [MS]" <prandal@.online.microsoft.com> wrote in message
> news:%23GZ7H38qEHA.708@.tk2msftngp13.phx.gbl...
> > You can't do that as the insert/exec creates a user transaction and
> > INDEXDEFRAG cannot run inside a user transaction. There's no way to
> > capture
> > the results from INDEXDEFRAG except using an external text file.
> >
> > Dan - what do you want to do with the values, out of interest?
> >
> > Regards
> >
> > --
> > Paul Randal
> > Dev Lead, Microsoft SQL Server Storage Engine
> >
> > This posting is provided "AS IS" with no warranties, and confers no
> > rights.
> >
> > "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote
> > in
> > message news:uZVSYG5qEHA.2732@.TK2MSFTNGP09.phx.gbl...
> >> Create a table with the same structure as the DBCC returns and then use
> > below technique:
> >>
> >> INSERT theTable
> >> EXEC('DBCC...')
> >>
> >> --
> >> Tibor Karaszi, SQL Server MVP
> >> http://www.karaszi.com/sqlserver/default.asp
> >> http://www.solidqualitylearning.com/
> >>
> >>
> >> "Dan" <dan.parker@._nospam_pro-bel.com> wrote in message
> >> news:uJ2XdA5qEHA.4044@.TK2MSFTNGP09.phx.gbl...
> >> > Hi All,
> >> >
> >> > I am writing a stored procedure that performs a DBCC INDEXDEFRAG on a
> > number of indexes.
> >> >
> >> > I wish to then manipulate the values from the result set (Pages
> >> > Scanned,
> > Pages Moved, Pages
> >> > Removed). However I cannot seem to find a way to do this
> >> >
> >> > Can anyone help please?
> >> >
> >> > Thanks in advance
> >> >
> >> > Dan
> >> >
> >>
> >>
> >
> >
>

obtaining return values from DBCC INDEXDEFRAG in a sp

Hi All,
I am writing a stored procedure that performs a DBCC INDEXDEFRAG on a number
of indexes.
I wish to then manipulate the values from the result set (Pages Scanned,
Pages Moved, Pages Removed). However I cannot seem to find a way to do this
Can anyone help please?
Thanks in advance
Dan
Create a table with the same structure as the DBCC returns and then use below technique:
INSERT theTable
EXEC('DBCC...')
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Dan" <dan.parker@._nospam_pro-bel.com> wrote in message
news:uJ2XdA5qEHA.4044@.TK2MSFTNGP09.phx.gbl...
> Hi All,
> I am writing a stored procedure that performs a DBCC INDEXDEFRAG on a number of indexes.
> I wish to then manipulate the values from the result set (Pages Scanned, Pages Moved, Pages
> Removed). However I cannot seem to find a way to do this
> Can anyone help please?
> Thanks in advance
> Dan
>
|||You can't do that as the insert/exec creates a user transaction and
INDEXDEFRAG cannot run inside a user transaction. There's no way to capture
the results from INDEXDEFRAG except using an external text file.
Dan - what do you want to do with the values, out of interest?
Regards
Paul Randal
Dev Lead, Microsoft SQL Server Storage Engine
This posting is provided "AS IS" with no warranties, and confers no rights.
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:uZVSYG5qEHA.2732@.TK2MSFTNGP09.phx.gbl...
> Create a table with the same structure as the DBCC returns and then use
below technique:[vbcol=seagreen]
> INSERT theTable
> EXEC('DBCC...')
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Dan" <dan.parker@._nospam_pro-bel.com> wrote in message
> news:uJ2XdA5qEHA.4044@.TK2MSFTNGP09.phx.gbl...
number of indexes.[vbcol=seagreen]
Pages Moved, Pages
>
|||Ah, thanks Paul. I didn't consider the transaction aspect of it...
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Paul S Randal [MS]" <prandal@.online.microsoft.com> wrote in message
news:%23GZ7H38qEHA.708@.tk2msftngp13.phx.gbl...
> You can't do that as the insert/exec creates a user transaction and
> INDEXDEFRAG cannot run inside a user transaction. There's no way to capture
> the results from INDEXDEFRAG except using an external text file.
> Dan - what do you want to do with the values, out of interest?
> Regards
> --
> Paul Randal
> Dev Lead, Microsoft SQL Server Storage Engine
> This posting is provided "AS IS" with no warranties, and confers no rights.
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
> message news:uZVSYG5qEHA.2732@.TK2MSFTNGP09.phx.gbl...
> below technique:
> number of indexes.
> Pages Moved, Pages
>
|||Hi Paul,
I want to put them into a "User Friendly" report, that basically lists the
time, index defragged and the pages scanned, moved, etc.
Regards
Dan
"Paul S Randal [MS]" <prandal@.online.microsoft.com> wrote in message
news:%23GZ7H38qEHA.708@.tk2msftngp13.phx.gbl...
> You can't do that as the insert/exec creates a user transaction and
> INDEXDEFRAG cannot run inside a user transaction. There's no way to
> capture
> the results from INDEXDEFRAG except using an external text file.
> Dan - what do you want to do with the values, out of interest?
> Regards
> --
> Paul Randal
> Dev Lead, Microsoft SQL Server Storage Engine
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote
> in
> message news:uZVSYG5qEHA.2732@.TK2MSFTNGP09.phx.gbl...
> below technique:
> number of indexes.
> Pages Moved, Pages
>
|||I'm afraid the only way to do it is to output the results to a flat file and
then post-process.
Regards
Paul Randal
Dev Lead, Microsoft SQL Server Storage Engine
This posting is provided "AS IS" with no warranties, and confers no rights.
"Dan" <dan.parker@._nospam_pro-bel.com> wrote in message
news:uE0WCTFrEHA.3428@.TK2MSFTNGP11.phx.gbl...
> Hi Paul,
> I want to put them into a "User Friendly" report, that basically lists the
> time, index defragged and the pages scanned, moved, etc.
> Regards
> Dan
>
> "Paul S Randal [MS]" <prandal@.online.microsoft.com> wrote in message
> news:%23GZ7H38qEHA.708@.tk2msftngp13.phx.gbl...
>