Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > How to retrieve the records if I have .SQL script file using ADO.net

Reply
Thread Tools

How to retrieve the records if I have .SQL script file using ADO.net

 
 
Kiran
Guest
Posts: n/a
 
      10-13-2003
Hi,
I need to retrieve records from SQL 2000 datbase using
ADO.Net
I have a huge select statement in .sql script file I need
to run it to get the records How Can I run it and get the
records

Can you guide me
 
Reply With Quote
 
 
 
 
bspann
Guest
Posts: n/a
 
      10-13-2003
Kiran,

I think what you are wanting to do is create a Stored Procedure in SQL
Server 2000. Then call the sp using ADO.NET. After ADO.NET gets the data,
it will be up to you as to how you would like to display the information
that is returned.

So the first thing to do is create the stored procedure.

Brian

"Kiran" <(E-Mail Removed)> wrote in message
news:059a01c391bf$e64ec990$(E-Mail Removed)...
> Hi,
> I need to retrieve records from SQL 2000 datbase using
> ADO.Net
> I have a huge select statement in .sql script file I need
> to run it to get the records How Can I run it and get the
> records
>
> Can you guide me



 
Reply With Quote
 
 
 
 
Kiran
Guest
Posts: n/a
 
      10-13-2003
Brian,
Thanks for the reply.

I do not have the option to create a stored proc.
All I have is *.sql script file with a big Select
statement in it.
I tried to read the file and pass that sql statement to
the sqlCommand object but due to the comments in the sql
file, command object is failing to execute when I call
command.CommandText = strSql;
command.CommandTimeout = 0;
SqlDataReader myReader = command.ExecuteReader();

but if I copy the contents of the .sql file and run in
query analyser window it runs.

I am wondering if I can pass the .sql file name to
retrieve the recordset object.

Thanks
Kiran


>-----Original Message-----
>Kiran,
>
>I think what you are wanting to do is create a Stored

Procedure in SQL
>Server 2000. Then call the sp using ADO.NET. After

ADO.NET gets the data,
>it will be up to you as to how you would like to display

the information
>that is returned.
>
>So the first thing to do is create the stored procedure.
>
>Brian
>
>"Kiran" <(E-Mail Removed)> wrote in message
>news:059a01c391bf$e64ec990$(E-Mail Removed)...
>> Hi,
>> I need to retrieve records from SQL 2000 datbase using
>> ADO.Net
>> I have a huge select statement in .sql script file I

need
>> to run it to get the records How Can I run it and get

the
>> records
>>
>> Can you guide me

>
>
>.
>

 
Reply With Quote
 
bspann
Guest
Posts: n/a
 
      10-13-2003
I don't understand why you do not have access to create a Stored Procedure
but you have access to run queries? Creating a view would be better that
passing SQL from your application to the database engine. Anyway, here is a
thought.

You will need to write a method that strips out the comments. Use a
StringBuilder object to create your SQL statement. This is a better
resource than appending strings together. Anyway, this should keep you busy
for a while. Also, look at the Regex object. That might come in handy.

Brian

"Kiran" <(E-Mail Removed)> wrote in message
news:069f01c391cb$741fde20$(E-Mail Removed)...
> Brian,
> Thanks for the reply.
>
> I do not have the option to create a stored proc.
> All I have is *.sql script file with a big Select
> statement in it.
> I tried to read the file and pass that sql statement to
> the sqlCommand object but due to the comments in the sql
> file, command object is failing to execute when I call
> command.CommandText = strSql;
> command.CommandTimeout = 0;
> SqlDataReader myReader = command.ExecuteReader();
>
> but if I copy the contents of the .sql file and run in
> query analyser window it runs.
>
> I am wondering if I can pass the .sql file name to
> retrieve the recordset object.
>
> Thanks
> Kiran
>
>
> >-----Original Message-----
> >Kiran,
> >
> >I think what you are wanting to do is create a Stored

> Procedure in SQL
> >Server 2000. Then call the sp using ADO.NET. After

> ADO.NET gets the data,
> >it will be up to you as to how you would like to display

> the information
> >that is returned.
> >
> >So the first thing to do is create the stored procedure.
> >
> >Brian
> >
> >"Kiran" <(E-Mail Removed)> wrote in message
> >news:059a01c391bf$e64ec990$(E-Mail Removed)...
> >> Hi,
> >> I need to retrieve records from SQL 2000 datbase using
> >> ADO.Net
> >> I have a huge select statement in .sql script file I

> need
> >> to run it to get the records How Can I run it and get

> the
> >> records
> >>
> >> Can you guide me

> >
> >
> >.
> >



 
Reply With Quote
 
Kiran
Guest
Posts: n/a
 
      10-14-2003
Hi Brian,
Other applications generate these script files so we
do not want to create thousands of stored procedures.
I tried to strip off the comments in the file and append
SQL statement in the file using stringBuilder it worked.
Thanks for your input.

It would be a Nice to have feature if some ADO oject
accepts *.sql script file and returns the recordset object.

Have a great day you Microsoft geeks

Thanks
Kiran

>-----Original Message-----
>I don't understand why you do not have access to create a

Stored Procedure
>but you have access to run queries? Creating a view

would be better that
>passing SQL from your application to the database

engine. Anyway, here is a
>thought.
>
>You will need to write a method that strips out the

comments. Use a
>StringBuilder object to create your SQL statement. This

is a better
>resource than appending strings together. Anyway, this

should keep you busy
>for a while. Also, look at the Regex object. That

might come in handy.
>
>Brian
>
>"Kiran" <(E-Mail Removed)> wrote in message
>news:069f01c391cb$741fde20$(E-Mail Removed)...
>> Brian,
>> Thanks for the reply.
>>
>> I do not have the option to create a stored proc.
>> All I have is *.sql script file with a big Select
>> statement in it.
>> I tried to read the file and pass that sql statement to
>> the sqlCommand object but due to the comments in the sql
>> file, command object is failing to execute when I call
>> command.CommandText = strSql;
>> command.CommandTimeout = 0;
>> SqlDataReader myReader = command.ExecuteReader();
>>
>> but if I copy the contents of the .sql file and run in
>> query analyser window it runs.
>>
>> I am wondering if I can pass the .sql file name to
>> retrieve the recordset object.
>>
>> Thanks
>> Kiran
>>
>>
>> >-----Original Message-----
>> >Kiran,
>> >
>> >I think what you are wanting to do is create a Stored

>> Procedure in SQL
>> >Server 2000. Then call the sp using ADO.NET. After

>> ADO.NET gets the data,
>> >it will be up to you as to how you would like to

display
>> the information
>> >that is returned.
>> >
>> >So the first thing to do is create the stored

procedure.
>> >
>> >Brian
>> >
>> >"Kiran" <(E-Mail Removed)> wrote in message
>> >news:059a01c391bf$e64ec990$(E-Mail Removed)...
>> >> Hi,
>> >> I need to retrieve records from SQL 2000 datbase

using
>> >> ADO.Net
>> >> I have a huge select statement in .sql script file I

>> need
>> >> to run it to get the records How Can I run it and get

>> the
>> >> records
>> >>
>> >> Can you guide me
>> >
>> >
>> >.
>> >

>
>
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Using For ... Loop to retrieve records.... David ASP General 14 06-20-2007 08:28 AM
Simple query returns 0 records in asp, but all records in vbscript masg0013@gmail.com ASP General 3 11-02-2006 09:23 AM
Delete records or update records Dan ASP General 1 05-10-2004 01:25 PM
match muliple header records to associated detail records Luke Airig XML 0 12-31-2003 12:06 AM



Advertisments