Showing posts with label user. Show all posts
Showing posts with label user. Show all posts

Friday, March 30, 2012

Need help connecting to server with DSN

Hi all,

I am used to connecting to my database using a querystring and a connection like this:


string connectionString = "server=\'myserver\'; user id=\'myuser\'; password=\'mypw;database=\'mydb\'";
System.Data.IDbConnection dbConnection = new System.Data.SqlClient.SqlConnection(connectionString);

I write in C# and don't know how to connect to a database using a DSN. I have this VB code that's supposed to connect with DSN:

<%
set conn = Server.CreateObject("ADODB.Connection")
conn.open"DSN=MyDSN;UID=user;PWD=password;DATABASE=databasename"
%>

But I need it in C#...

I tried using a query string like this one


string connectionString="DSN=mydsn;UID=myuser;PWD=mypw;DATABASE=mydb";

and got this error :Unknown connection option in connection string: dsn. :

Any help would be greatly appreciated... thanksPlease check the following :


OdbcConnection cn;
OdbcCommand cmd;
string MyString;

MyString="Select * from test";

cn= new OdbcConnection("dsn=myDSN;UID=myUid;PWD=myPwd;");
cmd=new OdbcCommand(MyString,cn);
cn.Open();
......

|||that's classic ASP code in VBScript - not ASP.NET code in VB.NET

Anyway, is there a particular reason you NEED to use a DSN? it IS possible, but it's not the best option.

Need help changing database dynamically

I have the following code. I basically want to dynamically empty all data
from every user table in every user database. I have the code that processe
s
all the databases I want and then gets all of the tables I want. My problem
is using the GO. I can't get this to run by writing USE @.dbname GO or
USE @.dbname
GO
Does anyone have a recommendation? I'm sure I have just been looking at it
to long at this point and it is easy. Thanks in advance.
-- Sydem
begin tran ProcessDataClean
declare @.dbname varchar(255)
declare @.dbtablename varchar(255)
declare @.sql varchar(255)
DECLARE ProcessDataClean_CURSOR CURSOR FOR
select name
from master.dbo.sysdatabases
where dbid > 6 and
name not in ('pubs', 'Northwinds')
order by name
OPEN ProcessDataClean_CURSOR
FETCH NEXT FROM ProcessDataClean_CURSOR INTO @.dbname
WHILE (@.@.FETCH_STATUS <> -1)
BEGIN
IF (@.@.fetch_status <> -2)
BEGIN
select @.sql = 'USE ' + @.dbname
exec sp_sqlexec @.sql
--i want to use GO right here to switch the database
--for now i'm just printing what i want to do
PRINT ''
PRINT @.sql
PRINT 'GO'
PRINT ''
DECLARE GetDBTableName_CURSOR CURSOR FOR
select name
from dbo.sysobjects
where OBJECTPROPERTY(id, N'IsUserTable') = 1
order by name
OPEN GetDBTableName_CURSOR
FETCH NEXT FROM GetDBTableName_CURSOR INTO @.dbtablename
WHILE (@.@.FETCH_STATUS <> -1)
BEGIN
IF (@.@.fetch_status <> -2)
BEGIN
PRINT 'DELETE ' + @.dbtablename
END
FETCH NEXT FROM GetDBTableName_CURSOR INTO @.dbtablename
END
CLOSE GetDBTableName_CURSOR
DEALLOCATE GetDBTableName_CURSOR
END
FETCH NEXT FROM ProcessDataClean_CURSOR INTO @.dbname
END
CLOSE ProcessDataClean_CURSOR
DEALLOCATE ProcessDataClean_CURSOR
commit tran ProcessDataClean[USE] does not accept a parameter / variable. You will have to execute the
rest of the code inside the context where you are suing "use database_name".
Example:
exec sp_msforeachdb '
if ''?'' not in (
''master'',
''msdb'',
''model'',
''tempdb'',
''pubs'',
''northwind''
)
begin
use [?]
select
table_catalog,
table_name
from
information_schema.tables
end
'
This is an example (may be a bad one), i am not recommending to use the
undocumented and unsupported sp sp_msforeachdb.
Anyway if you try to delete from tables being referenced by other tables,
you will get an error. I think it will be better if you drop the databases
and recreate them.
AMB
"Sydem" wrote:

> I have the following code. I basically want to dynamically empty all data
> from every user table in every user database. I have the code that proces
ses
> all the databases I want and then gets all of the tables I want. My probl
em
> is using the GO. I can't get this to run by writing USE @.dbname GO or
> USE @.dbname
> GO
> Does anyone have a recommendation? I'm sure I have just been looking at i
t
> to long at this point and it is easy. Thanks in advance.
> -- Sydem
>
> begin tran ProcessDataClean
> declare @.dbname varchar(255)
> declare @.dbtablename varchar(255)
> declare @.sql varchar(255)
> DECLARE ProcessDataClean_CURSOR CURSOR FOR
> select name
> from master.dbo.sysdatabases
> where dbid > 6 and
> name not in ('pubs', 'Northwinds')
> order by name
> OPEN ProcessDataClean_CURSOR
> FETCH NEXT FROM ProcessDataClean_CURSOR INTO @.dbname
> WHILE (@.@.FETCH_STATUS <> -1)
> BEGIN
> IF (@.@.fetch_status <> -2)
> BEGIN
> select @.sql = 'USE ' + @.dbname
> exec sp_sqlexec @.sql
> --i want to use GO right here to switch the database
> --for now i'm just printing what i want to do
> PRINT ''
> PRINT @.sql
> PRINT 'GO'
> PRINT ''
> DECLARE GetDBTableName_CURSOR CURSOR FOR
> select name
> from dbo.sysobjects
> where OBJECTPROPERTY(id, N'IsUserTable') = 1
> order by name
> OPEN GetDBTableName_CURSOR
> FETCH NEXT FROM GetDBTableName_CURSOR INTO @.dbtablename
> WHILE (@.@.FETCH_STATUS <> -1)
> BEGIN
> IF (@.@.fetch_status <> -2)
> BEGIN
> PRINT 'DELETE ' + @.dbtablename
> END
> FETCH NEXT FROM GetDBTableName_CURSOR INTO @.dbtablename
> END
> CLOSE GetDBTableName_CURSOR
> DEALLOCATE GetDBTableName_CURSOR
> END
> FETCH NEXT FROM ProcessDataClean_CURSOR INTO @.dbname
> END
> CLOSE ProcessDataClean_CURSOR
> DEALLOCATE ProcessDataClean_CURSOR
> commit tran ProcessDataClean|||Correction,

> Anyway if you try to delete from tables being referenced by other tables,
> you will get an error.
Anyway, if you try to delete from tables being referenced by other tables
and there are rows related in the child table, you will get an error.
Example:
exec ('use northwind delete [dbo].[orders]')
go
AMB
"Alejandro Mesa" wrote:
> [USE] does not accept a parameter / variable. You will have to execute the
> rest of the code inside the context where you are suing "use database_name
".
> Example:
> exec sp_msforeachdb '
> if ''?'' not in (
> ''master'',
> ''msdb'',
> ''model'',
> ''tempdb'',
> ''pubs'',
> ''northwind''
> )
> begin
> use [?]
> select
> table_catalog,
> table_name
> from
> information_schema.tables
> end
> '
> This is an example (may be a bad one), i am not recommending to use the
> undocumented and unsupported sp sp_msforeachdb.
> Anyway if you try to delete from tables being referenced by other tables,
> you will get an error. I think it will be better if you drop the databases
> and recreate them.
>
> AMB
> "Sydem" wrote:
>|||Great Alejandro. I will take a look at that.
"Alejandro Mesa" wrote:
> Correction,
>
> Anyway, if you try to delete from tables being referenced by other tables
> and there are rows related in the child table, you will get an error.
> Example:
> exec ('use northwind delete [dbo].[orders]')
> go
>
> AMB
> "Alejandro Mesa" wrote:
>

Monday, March 26, 2012

Need Help

I have a web app in asp.net which has 8 textboxes

the user searches the database and the search result is shown in a datagrid

the user has the option to select any records displayed using a checkbox

and they can enter values into the textboxes (or leave it empty) and when they say edit

the app updates the database the selected rows with values from the 8 textboxes id any of the text boxes are empty or "" then the existing value in that column has to be retained if the text box is not empty then then the new value is updated

the way i am doing it now is putting the update statement in a for loop and checking if the text box is not null and then updating the DB for that row

the problem is that if the user selects 5000 rows then the app has to do 5000 updates.

and it is a big performance problem

I want to do this update in the SQL 2000 by using a Stored Proc or do I need to use a Cursor

can somebody help me with small code snippet ..

Thanks

PKGCan you show us some code? Like what the update looks like?

In your case though, I might use a work table...and do the updates on the server...|||Originally posted by Brett Kaiser
Can you show us some code? Like what the update looks like?

In your case though, I might use a work table...and do the updates on the server...

here is a sample update statement

UPDATE BIRECIN SET GLDEBIT = '789945562.524', GLCREDIT ='74859612.586' WHERE EntryClass = 'AADM' and AccCode ='MDH' and RevArea='CCU '

then..


UPDATE BIRECIN SET GLDEBIT = '789945562.524', GLCREDIT ='74859612.586' WHERE EntryClass = 'AAFM' and AccCode ='MDH' and RevArea='CCI '

this update statement is inside a for loop and gets executed for n number of rows|||Use the isnull function

Update YourTable
Set YourExistingValue = isnull(@.YourNewValue, YourExistingValue)
From YourTable
Where Keyfield = @.KeyField

If @.YourNewValue is null, the old value is retained.

If you can't submit null values, but have to submit zero-length strings instead, this should work:
Set YourExistingValue = isnull(null(@.YourNewValue, ''), YourExistingValue)

blindman|||Yeah, ok, but he wants to update an entire record set back to the database...

How would you do that...

He says he's looping like 5,000 times...

How do you get the data?|||I get it. The table he is updating with the check boxes isn't in SQL server. It's a dataset in his asp page?

Criminy. That's an asp problem, and out of my scope.

blindman|||Is there some way in asp to write the records (or just the checked ones) back into a temporary table that he could then join to his raw data tables?

blindman|||Yeah, that's what I was thinking, so he could do a set based op instead..

like bcp the data or is there an asp method...

There's got to be asp forums someplace...

We got the db section covered|||How about ...

Here (http://www.dbforums.com/forumdisplay.php?forumid=192)

Guys .. dont you ever look outside
dBforums Database Server Software Microsoft SQL Server|||Originally posted by Enigma
How about ...

Here (http://www.dbforums.com/forumdisplay.php?forumid=192)

Guys .. dont you ever look outside
dBforums Database Server Software Microsoft SQL Server

Sure do:

http://www.sqlteam.com/default.asp

Front end stuff...No thanks...see what a vb developer is making?

Enough to muddle through...not enough to be tapped to code...

The horror...the sheer horror...

Besides...I make all of the developers call stored procedures...they just present what I give them..|||The way the world should be. We cook the food. They can arrange it on the plate. Bon apetit', and my complements to the chef.

blindman|||Originally posted by blindman
The way the world should be. We cook the food. They can arrange it on the plate. Bon apetit', and my complements to the chef.

blindman

That's a GREAT analogy...

Need guidence on notifing when a new users is added

I have a SQL 2000 satabase that has multiple administrators for it and I nee
d
to know when a new user is added to the server. Can you provide some
suggestions on how to accpmplosh this task?"Jim Abel" <JimAbel@.discussions.microsoft.com> wrote in message
news:9416DA88-2F96-467A-A5DD-ED051E96A99D@.microsoft.com...
>I have a SQL 2000 satabase that has multiple administrators for it and I
>need
> to know when a new user is added to the server. Can you provide some
> suggestions on how to accpmplosh this task?
Do you mean a new LOGIN or a new USER (or both)?
SELECT name, createdate
FROM sysusers
WHERE createdate >= '2006-01-23T00:00:00.000';
SELECT name, createdate
FROM master.dbo.syslogins
WHERE createdate >= '2006-01-23T00:00:00.000';
You could create a job to run these queries once a day or once an hour and
email you the result.
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--

Friday, March 23, 2012

Need Enterprise Manager for Remote Site

I need to get Enterprise Manager to a user at a remote site and I don't want
to provide shared access to my sql 2000 install cd.
What/where can I download to provide a user with the Enterprise Manager mmc
console snap-in?
Thanks
Paul Bergson
If that is a "licenced" user, you can get him a copy of the cd, but if he is
not licenced he is not allowed to install it. There is no snap in
downloadable for the enterprise manager, it all comes with the cd.
Another options would be: http://www.aspfaq.com/show.asp?id=2442
HTH, Jens Suessmeyer.
"Paul Bergson" wrote:

> I need to get Enterprise Manager to a user at a remote site and I don't want
> to provide shared access to my sql 2000 install cd.
> What/where can I download to provide a user with the Enterprise Manager mmc
> console snap-in?
>
> --
> Thanks
> Paul Bergson
>
>
|||Paul Bergson wrote:
> I need to get Enterprise Manager to a user at a remote site and I
> don't want to provide shared access to my sql 2000 install cd.
> What/where can I download to provide a user with the Enterprise
> Manager mmc console snap-in?
Try using the SQL Server Web Data Administrator instead:
http://www.microsoft.com/downloads/d...displaylang=en
David Gugick
Quest Software
www.imceda.com
www.quest.com
sql

Need Enterprise Manager for Remote Site

I need to get Enterprise Manager to a user at a remote site and I don't want
to provide shared access to my sql 2000 install cd.
What/where can I download to provide a user with the Enterprise Manager mmc
console snap-in?
Thanks
Paul BergsonIf that is a "licenced" user, you can get him a copy of the cd, but if he is
not licenced he is not allowed to install it. There is no snap in
downloadable for the enterprise manager, it all comes with the cd.
Another options would be: http://www.aspfaq.com/show.asp?id=2442
HTH, Jens Suessmeyer.
"Paul Bergson" wrote:

> I need to get Enterprise Manager to a user at a remote site and I don't wa
nt
> to provide shared access to my sql 2000 install cd.
> What/where can I download to provide a user with the Enterprise Manager mm
c
> console snap-in?
>
> --
> Thanks
> Paul Bergson
>
>|||Paul Bergson wrote:
> I need to get Enterprise Manager to a user at a remote site and I
> don't want to provide shared access to my sql 2000 install cd.
> What/where can I download to provide a user with the Enterprise
> Manager mmc console snap-in?
Try using the SQL Server Web Data Administrator instead:
http://www.microsoft.com/downloads/...&displaylang=en
David Gugick
Quest Software
www.imceda.com
www.quest.com

Need Enterprise Manager for Remote Site

I need to get Enterprise Manager to a user at a remote site and I don't want
to provide shared access to my sql 2000 install cd.
What/where can I download to provide a user with the Enterprise Manager mmc
console snap-in?
--
Thanks
Paul BergsonIf that is a "licenced" user, you can get him a copy of the cd, but if he is
not licenced he is not allowed to install it. There is no snap in
downloadable for the enterprise manager, it all comes with the cd.
Another options would be: http://www.aspfaq.com/show.asp?id=2442
HTH, Jens Suessmeyer.
"Paul Bergson" wrote:
> I need to get Enterprise Manager to a user at a remote site and I don't want
> to provide shared access to my sql 2000 install cd.
> What/where can I download to provide a user with the Enterprise Manager mmc
> console snap-in?
>
> --
> Thanks
> Paul Bergson
>
>|||Paul Bergson wrote:
> I need to get Enterprise Manager to a user at a remote site and I
> don't want to provide shared access to my sql 2000 install cd.
> What/where can I download to provide a user with the Enterprise
> Manager mmc console snap-in?
Try using the SQL Server Web Data Administrator instead:
http://www.microsoft.com/downloads/details.aspx?FamilyID=c039a798-c57a-419e-acbc-2a332cb7f959&displaylang=en
David Gugick
Quest Software
www.imceda.com
www.quest.com

Monday, March 12, 2012

Need advice on searching text fields

I have a table with 2 million + rows. I need to allow the user to do a quer
y
such as is shown below. I have full text search enabled on this database,
and have built a text search catalog for it. The problem is, that I keep
getting timeouts on the query. Granted, I can increase the timout value to
a
value that works, but I need this to come back fairly quick. I need advice
on how to set up this application. Think of eBay. You can search on any
term. They have to have millions of rows in their database also. How do
they return results so quick? They have to be doing very similar query logi
c?
Select * From [Table] Where ([Field1] + [Field2] Like '%term1%')
AND ([Field1] + [Field2] Like '%term2%')Does the LIKE operator utilize the full-text search engine? Perhaps you be
using the CONTAINS and FREETEXT functions instead.
"Brian Kitt" <BrianKitt@.discussions.microsoft.com> wrote in message
news:88ECA16B-12D3-4AE9-ABDB-E666A633F381@.microsoft.com...
>I have a table with 2 million + rows. I need to allow the user to do a
>query
> such as is shown below. I have full text search enabled on this database,
> and have built a text search catalog for it. The problem is, that I keep
> getting timeouts on the query. Granted, I can increase the timout value
> to a
> value that works, but I need this to come back fairly quick. I need
> advice
> on how to set up this application. Think of eBay. You can search on any
> term. They have to have millions of rows in their database also. How do
> they return results so quick? They have to be doing very similar query
> logic?
> Select * From [Table] Where ([Field1] + [Field2] Like '%term1%')
> AND ([Field1] + [Field2] Like
> '%term2%')|||Oh, I assumed that 'Like' utilized the full text engine. Maybe I'm wrong.
I'll try the other two verbs and see what happens.
"JT" wrote:

> Does the LIKE operator utilize the full-text search engine? Perhaps you be
> using the CONTAINS and FREETEXT functions instead.
> "Brian Kitt" <BrianKitt@.discussions.microsoft.com> wrote in message
> news:88ECA16B-12D3-4AE9-ABDB-E666A633F381@.microsoft.com...
>
>|||Perhaps you're not taking advantage of the full text search with the
LIKE and the concatenated columns.
Try using FREETEXT instead of LIKE
... where ( FREETEXT (Field1, 'term1') or FREETEXT(Field2, 'term1') )
and ( FREETEXT (Field1, 'term2') or FREETEXT(Field2, 'term2') )
Brian Kitt wrote:
> I have a table with 2 million + rows. I need to allow the user to do a qu
ery
> such as is shown below. I have full text search enabled on this database,
> and have built a text search catalog for it. The problem is, that I keep
> getting timeouts on the query. Granted, I can increase the timout value t
o a
> value that works, but I need this to come back fairly quick. I need advic
e
> on how to set up this application. Think of eBay. You can search on any
> term. They have to have millions of rows in their database also. How do
> they return results so quick? They have to be doing very similar query lo
gic?
> Select * From [Table] Where ([Field1] + [Field2] Like '%term1%')
> AND ([Field1] + [Field2] Like '%term2%')[/colo
r]|||Even with the full-text search functioning, you may not get the crisp
response time you are looking for. After all, eBay has more processing power
at their disposal than 95% of us do.
"Brian Kitt" <BrianKitt@.discussions.microsoft.com> wrote in message
news:13DF6525-9595-41EB-B413-844EC57A09F2@.microsoft.com...
> Oh, I assumed that 'Like' utilized the full text engine. Maybe I'm wrong.
> I'll try the other two verbs and see what happens.
> "JT" wrote:
>|||Brian,
I can assure that T-SQL LIKE does NOT use the same technology as the
Full-Text Search (FTS) predicates of CONTAINS or FREETEXT !!
-- John
SQL Full Text Search Blog
http://spaces.msn.com/members/jtkane/
"Brian Kitt" <BrianKitt@.discussions.microsoft.com> wrote in message
news:13DF6525-9595-41EB-B413-844EC57A09F2@.microsoft.com...
> Oh, I assumed that 'Like' utilized the full text engine. Maybe I'm wrong.
> I'll try the other two verbs and see what happens.
> "JT" wrote:
>|||Brian,
While you may not have the processing power of eBay, you can get good
performance out of FTS with a bit of tuning on both the FT Indexing (Change
Tracking with Update Index in Background) and with using CONTAINSTABLE or
FREETEXTTABLE with the Top_N_Rank parameter and limiting your results to the
top 2000 by RANK, for example:
SELECT TOP 200 T.* FROM TableWithFTColumn as T,
CONTAINSTABLE(TableWIthFTColumn,*,'John'
,300) as CT
WHERE T.key=CT.key AND T.a > 5
ORDER BY CT.rank
Where 300 is the Top_N_by_RANK value. See KB artilce 240833 "FIX: Full-Text
Search Performance Improved via Support for TOP" at
http://support.microsoft.com//defau...kb;EN-US;240833 for more
details. Also, review SQL Server 200 Books Online (BOL) title "Full-text
Search Recommendations" for more tips!
Regards,
John
--
SQL Full Text Search Blog
http://spaces.msn.com/members/jtkane/
"JT" <someone@.microsoft.com> wrote in message
news:O2tY0S8sFHA.1940@.TK2MSFTNGP14.phx.gbl...
> Even with the full-text search functioning, you may not get the crisp
> response time you are looking for. After all, eBay has more processing
> power at their disposal than 95% of us do.
> "Brian Kitt" <BrianKitt@.discussions.microsoft.com> wrote in message
> news:13DF6525-9595-41EB-B413-844EC57A09F2@.microsoft.com...
>

Need Advice on Reporting, End User Query and Data warehousing Tools

Hi:
I need an advice on Reporting, End User Query and Data warehousing
Tools
Below is my customer requirement:
Reporting:
- Flexible Reporting and Web Publishing
- Development and / or customization of reports by systems users using
a GUI based reports designer
- Export Capability to Office Automation Software
- Charting Facility
- Browser-Based User Interface
End User Query:
- Export Capability to Office Automation Software
- Web Publishing Output
- Charting Facility
- Reporting Facility
- Browser-Based User Interface
- Performance Monitoring/Tracking
- Administration
- Row and Column Level Security
Data warehouse:
- ETL and Analyst Tools
SQL2005 Enterprise, SSIS, SSAS, SSRS and Report Builder seem to meet
the requirement, but the problem is the target database is Oracle10g,
can i use those services on Oracle database ?
How about the solution from BusinessObject and Microstrategy, compare
with the services from SQL2005 Enterprise ?
Please Help.
Thanks
JCvoonHi
Reporting Services will certainly cover all your reporting needs including
the automatic generation and delivery that you have specified. You may want
to read the articles at
http://www.microsoft.com/sql/technologies/reporting/default.mspx if you have
not already. It sounds like you will not be running reports directly of you
Oracle database (which I think is possible although I have no experience of
doing this), but using Analysis Services will eliminate the need query this
data http://www.microsoft.com/sql/technologies/analysis/default.mspx.
An important factor will be a good design of the data warehouse. A poor
design will make reporting significantly more difficult, regardless of the
tool used. After using Business Objects a little I would say that for report
generation I do prefer Reporting Services.
One of the biggest factors may be licencing costs, if you are already a SQL
Server house, you will have not extra licence costs for AS or RS.
HTH
John
"jcvoon" wrote:
> Hi:
> I need an advice on Reporting, End User Query and Data warehousing
> Tools
> Below is my customer requirement:
> Reporting:
> - Flexible Reporting and Web Publishing
> - Development and / or customization of reports by systems users using
> a GUI based reports designer
> - Export Capability to Office Automation Software
> - Charting Facility
> - Browser-Based User Interface
> End User Query:
> - Export Capability to Office Automation Software
> - Web Publishing Output
> - Charting Facility
> - Reporting Facility
> - Browser-Based User Interface
> - Performance Monitoring/Tracking
> - Administration
> - Row and Column Level Security
> Data warehouse:
> - ETL and Analyst Tools
>
> SQL2005 Enterprise, SSIS, SSAS, SSRS and Report Builder seem to meet
> the requirement, but the problem is the target database is Oracle10g,
> can i use those services on Oracle database ?
> How about the solution from BusinessObject and Microstrategy, compare
> with the services from SQL2005 Enterprise ?
> Please Help.
> Thanks
> JCvoon
>|||John Bell:
Thanks for your reply.
In fact I plan to use the SSRS to generate report from Oracle database,
and use SSIS to build the Oracle data warehouse, for SSRS I think it
shouldn't be a problem, but for SSIS and SSAS I'm not sure.
Regards
JCVoon

Friday, March 9, 2012

Need advice for Parent Child simultaneusly insert by many user


Need advice for Parent Child insert in transaction mode
I have Parent child table as decribe below:
Parent Table name = TESTPARENT
1. counter bigint isIdentity=Yes Increment=1 Seed=1
2. customer nChar(10)
Child Table name = TESTCHILD
1. counter bigint
2. qty numeric(3,0)
I want to insert new record with code below:
void button1_Click(object sender, EventArgs e)
{
// Define object to catch @.@.indentity
object myCounter;
// Connect to database & open
myConnection = new SqlConnection("Data Source=SQL2005;Initial
Catalog=XXX;User ID=sa; Password=YYY");
myConnection.Open();
// define transaction
SqlTransaction myAtom = myConnection.BeginTransaction();
SqlCommand myAtomCmd = myConnection.CreateCommand();
myAtomCmd.Transaction = myAtom;
// Start insert to database with transaction mode
try
{
// Insert parent new record
myAtomCmd.CommandText = string.Format("insert into TESTPARENT (customer)
values ('{0}')", tbCustomer.Text);
myAtomCmd.ExecuteNonQuery();
// Get Indentity
myAtomCmd.CommandText = "SELECT @.@.identity from testParent";
myCounter = myAtomCmd.ExecuteScalar();
// insert child new record
myAtomCmd.CommandText = string.Format("insert into TESTCHILD (counter,
qty) values ('{0}', {1})", Convert.ToInt64(myCounter.ToString()),
tbQty.Value);
myAtomCmd.ExecuteNonQuery();
// Commit transaction
myAtom.Commit();
}
catch
{
myAtom.Rollback();
MessageBox.Show("Data not inserted");
}
}
I already try with 2 workstation and 1 server, that code working well
(not duplicate in parent and insert right relation child parent record
in child table ).
I am not sure that code will stay stable when the table inserted
simultaneusly by many user.
Please advice, that code is the right way.
*** Sent via Developersdex http://www.examnotes.net ***The DBA side of me is cringing, becuae you're not using stored
procedures to insert data into a database; you really should use a
stored procedure when running against SQL Server. I realize that there
may be reasons to not use a stored procedure, but thos should be the
exception, and not the rule. Oh, and if you're going to use IDENTITY
columns, you should probably be using SCOPE_IDENTITY, and not
@.@.IDENTITY to return the last value inserted.
The developer side of me (recognizing that this might be one of those
rare times when a stored procedure is not appropriate) is cringing
because you are not using parameters to issue commands to your
database, thereby opening yourself up to SQL injection. You are also
connecting to your database as "sa", which means that if someone
figures out your connection string, they own your server.
Try replacing the value of tbCustomer.Text with "1'); DROP TABLE
TestParent--" and see what happens.
You need to make the following changes:
1. Don't connect to a database using sa; create a user with the
appropriate permissions.
2. Use a stored procedure for all CRUD operations (if you don't know
what CRUD stands for, Google it; it'll help you understand a lot more
that this single post will explain).
3. If you can't use a stored procedure (vendor issue, server doesn't
support stored procedures, etc), then use parameters on your client
side; don't build strings.
HTH,
Stu

Need a way to handle multiple selections

I have a webform that lists all items (codes) on the left and selected items (codes) on the right. A user selects an item on the left and clicks a button to move it to the right side. An update changes the bit from 0 to 1. This uses the bit column in the table to determine what is listed on the left (0) or right (1) sides.

Then I can filter in my stored procedure on the bit column WHERE (dbo.tblCodes.CodeSelect = 1)

My problem with this is that if two or more users are doing this process on different sessions, they can trip over each others selections.

I'm hoping someone has a suggestion on how I might avoid the users having this problem.

Arent you storing the selections into a temp table before you update the actual tables?

|||

No, the user selects a code from a listbox on the left and clicks a button. This button calls a stroed procedure that changes the bit column of that code to 1 and then on postback it is moved to the right side. Once they have made all their selections another stored procedure is called to get the data based on their selection.

The update procedure looks like this:

ALTER PROCEDURE [dbo].[CodeSelectOne](@.SelectOneint)
AS UPDATE dbo.tblCodeLookup
SET [CodeSelect] = 1
WHERE (Code_ID = @.SelectOne)

I think my issue is in the next procedure that returnes the data to the user. That procedure uses a where clause WHERE tblCodeLookup.CodeSelect = 1, I think this is where I run into trouble. If another user changes the selected codes before this first users data is returned then they will not get there expected data.

Any suggestions?

|||

What if I had a multiselect listbox and put a comma delimited list of codes in a session varaible and then pass that to my stored procedure in a correlated subquery using an IN?

Any thoughts on this?

Wednesday, March 7, 2012

Need a little help please

I have a simple table:
MyTable
id int null
user varchar(50) null
desc varchar(150) null
No PK or indexes of any kind.
Does the following cause any performance issue:
insert into MyTable (desc, user, id) values ('Bob from Account
Temps','Bob','777')
Does not having indexes or PK hinder the insert? And does the order of the
columns in the insert make a difference?
Thanks all
JDEvery table should have a primary key. Why do you have a table without
one?
> Does not having indexes or PK hinder the insert?
A lack of indexes and constraints doesn't affect the insert per se.
Potentially it affects the *validity* of the insert since you won't be
prevented from inserting redundant data.
> And does the order of the
> columns in the insert make a difference?
If all the column names are listed then logically the order makes no
difference.
--
David Portas
SQL Server MVP
--|||This is a 3rd party application. I'm trying to gather information what will
be presented at a meeting next week.
thanks for the feedback.
JD
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:1108586063.090431.233100@.l41g2000cwc.googlegroups.com...
> Every table should have a primary key. Why do you have a table without
> one?
> > Does not having indexes or PK hinder the insert?
> A lack of indexes and constraints doesn't affect the insert per se.
> Potentially it affects the *validity* of the insert since you won't be
> prevented from inserting redundant data.
> > And does the order of the
> > columns in the insert make a difference?
> If all the column names are listed then logically the order makes no
> difference.
> --
> David Portas
> SQL Server MVP
> --
>|||>> Does not having indexes or PK hinder the insert?
> A lack of indexes and constraints doesn't affect the insert per se.
It can, but the effect will probably only surface under more extreme conditions.
If there is a clustered index, SQL Server will immediately know where to put this row. If the cl ix
key is always increasining (which isn't necessarily the optimal cl ix key for *searches*), then you
won't get page splits either.
If there isn't a cl ix, then SQL Server need to go by IAMs and PFS pages (I believe, it is still
early in the morning for me) to determine where to put the rows. I imagine that this can be more
work, but I doubt we see the effect unless large databases and heavy load.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:1108586063.090431.233100@.l41g2000cwc.googlegroups.com...
> Every table should have a primary key. Why do you have a table without
> one?
>> Does not having indexes or PK hinder the insert?
> A lack of indexes and constraints doesn't affect the insert per se.
> Potentially it affects the *validity* of the insert since you won't be
> prevented from inserting redundant data.
>> And does the order of the
>> columns in the insert make a difference?
> If all the column names are listed then logically the order makes no
> difference.
> --
> David Portas
> SQL Server MVP
> --
>

Need a Help on Query

Hi, All
I am using three tables, called WEB_SITE , USER_INFO and HEALTHFORM. The user who login from USER_INFO, wants to see all the data in HEALTHFORM filled by him. One user can filled many Health Forms. The user who fills the health form will get one new Web_ ID from WEB_SITE. Trying to call a QUERY to retrieve all the data by user name and password. I am trying to make a web site like net doctor, using cold fusion. Any help would be appreciated.Here is a clue: you need to read this (http://www.1keydata.com/sql/sql.html) and this (http://www.geocities.com/SiliconValley/Vista/2207/sql1.html) and this (http://www.w3schools.com/sql/default.asp). :D

Need a hand...

i've been writing an app for my company that has a front end screen in which the user types in all infos needed (ie. name, address, city, state, etc - 82 fields to be exact) then clicks an "add" button, which i put at the bottom, and have that data dumped into a SQL table... the page is then redirected to another page which reads the record just added and displays all the fields that the user submitted...

here is my front end "add" screen code behind written in C#:

using System;

using System.Data;

using System.Data.SqlClient;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

publicpartialclassVinny_Credit_Application_AddCredApp : System.Web.UI.Page

{

protectedvoid Page_Load(object sender,EventArgs e)

{

}

protectedvoid SubmitButton_Click(object sender,EventArgs e)

{

string ConnectionString =ConfigurationManager.ConnectionStrings["ws2dbConnectionString2"].ConnectionString;

SqlConnection connection =newSqlConnection(ConnectionString);

SqlCommand cmd =newSqlCommand(@."INSERT INTO CreditAppFile (

GI_RB_Div,

GI_RB_ExistCust,

GI_TB_LegalFirmName,

GI_TB_Address,

GI_TB_City,

GI_DDL_State,

GI_TB_Zip,

GI_TB_TradeName,

GI_TB_BillAddress,

GI_TB_BillCity,

GI_DDL_BillState,

GI_TB_BillZip,

GI_TB_ContName,

GI_TB_Title,

GI_TB_MobilePager,

GI_TB_Email,

GI_TB_Fax,

GI_TB_BusDesc,

GI_TB_BusStartDate,

GI_TB_BusPhone,

GI_RB_PuchOrdsReq,

GI_RB_BusType,

GI_RB_LiensJudges,

GI_RB_TaxExempt,

GI_TB_FedIDNO,

GI_RB_PriorBankrupt,

GI_TB_PriorBankr,

BFR_TB_ContPhone,

BFR_TB_AcctNum1,

BFR_TB_AcctNum2,

BFR_TB_CurrBal1,

BFR_TB_CurrBal2,

BFR_TB_CurrBal3,

BFR_TB_CurrBal4,

BFR_RB_AcctType,

TR_TB_ContName1,

TR_TB_ContAddr1,

TR_TB_ContCity1,

TR_DDL_ContSt1,

TR_TB_ContZip1,

TR_TB_ContPhone1,

TR_TB_Cont_Acct1,

TR_TB_ContName2,

TR_TB_ContAddr2,

TR_TB_ContCity2,

TR_DDL_ContSt2,

TR_TB_ContZip2,

TR_TB_ContPhone2,

TR_TB_Cont_Acct2,

TR_TB_ContName3,

TR_TB_ContAddr3,

TR_TB_ContCity3,

TR_DDL_ContSt3,

TR_TB_ContZip3,

TR_TB_ContPhone3,

TR_TB_Cont_Acct3,

PI_TB_Name1,

PI_TB_HomeAddr1,

PI_TB_BDay1,

PI_TB_SSNum1,

PI_TB_HomePh1,

PI_TB_PrcntOwn1,

PI_TB_NetWorth1,

PI_TB_AnnInc1,

PI_TB_MonHouPay1,

PI_TB_Name2,

PI_TB_HomeAddr2,

PI_TB_BDay2,

PI_TB_SSNum2,

PI_TB_HomePh2,

PI_TB_PrcntOwn2,

PI_TB_NetWorth2,

PI_TB_AnnInc2,

PI_TB_MonHouPay2,

PI_TB_Name3,

PI_TB_HomeAddr3,

PI_TB_BDay3,

PI_TB_SSNum3,

PI_TB_HomePh3,

PI_TB_PrcntOwn3,

PI_TB_NetWorth3,

PI_TB_AnnInc3,

PI_TB_MonHouPay3

)

VALUES (

@.GI_RB_Div,

@.GI_RB_ExistCust,

@.GI_TB_LegalFirmName,

@.GI_TB_Address,

@.GI_TB_City,

@.GI_DDL_State,

@.GI_TB_Zip,

@.GI_TB_TradeName,

@.GI_TB_BillAddress,

@.GI_TB_BillCity,

@.GI_DDL_BillState,

@.GI_TB_BillZip,

@.GI_TB_ContName,

@.GI_TB_Title,

@.GI_TB_MobilePager,

@.GI_TB_Email,

@.GI_TB_Fax,

@.GI_TB_BusDesc,

@.GI_TB_BusStartDate,

@.GI_TB_BusPhone,

@.GI_RB_PuchOrdsReq,

@.GI_RB_BusType,

@.GI_RB_LiensJudges,

@.GI_RB_TaxExempt,

@.GI_TB_FedIDNO,

@.GI_RB_PriorBankrupt,

@.GI_TB_PriorBankr,

@.BFR_TB_ContPhone,

@.BFR_TB_AcctNum1,

@.BFR_TB_AcctNum2,

@.BFR_TB_CurrBal1,

@.BFR_TB_CurrBal2,

@.BFR_TB_CurrBal3,

@.BFR_TB_CurrBal4,

@.BFR_RB_AcctType,

@.TR_TB_ContName1,

@.TR_TB_ContAddr1,

@.TR_TB_ContCity1,

@.TR_DDL_ContSt1,

@.TR_TB_ContZip1,

@.TR_TB_ContPhone1,

@.TR_TB_Cont_Acct1,

@.TR_TB_ContName2,

@.TR_TB_ContAddr2,

@.TR_TB_ContCity2,

@.TR_DDL_ContSt2,

@.TR_TB_ContZip2,

@.TR_TB_ContPhone2,

@.TR_TB_Cont_Acct2,

@.TR_TB_ContName3,

@.TR_TB_ContAddr3,

@.TR_TB_ContCity3,

@.TR_DDL_ContSt3,

@.TR_TB_ContZip3,

@.TR_TB_ContPhone3,

@.TR_TB_Cont_Acct3,

@.PI_TB_Name1,

@.PI_TB_HomeAddr1,

@.PI_TB_BDay1,

@.PI_TB_SSNum1,

@.PI_TB_HomePh1,

@.PI_TB_PrcntOwn1,

@.PI_TB_NetWorth1,

@.PI_TB_AnnInc1,

@.PI_TB_MonHouPay1,

@.PI_TB_Name2,

@.PI_TB_HomeAddr2,

@.PI_TB_BDay2,

@.PI_TB_SSNum2,

@.PI_TB_HomePh2,

@.PI_TB_PrcntOwn2,

@.PI_TB_NetWorth2,

@.PI_TB_AnnInc2,

@.PI_TB_MonHouPay2,

@.PI_TB_Name3,

@.PI_TB_HomeAddr3,

@.PI_TB_BDay3,

@.PI_TB_SSNum3,

@.PI_TB_HomePh3,

@.PI_TB_PrcntOwn3,

@.PI_TB_NetWorth3,

@.PI_TB_AnnInc3,

@.PI_TB_MonHouPay3

); Select Scope_Identity()"

, connection);

try

{

cmd.Parameters.AddWithValue("@.GI_RB_Div", GI_RB_Div.SelectedValue);

cmd.Parameters.AddWithValue("@.GI_RB_ExistCust", GI_RB_ExistCust.SelectedValue);

cmd.Parameters.AddWithValue("@.GI_TB_LegalFirmName", GI_TB_LegalFirmName.Text);

cmd.Parameters.AddWithValue("@.GI_TB_Address", GI_TB_Address.Text);

cmd.Parameters.AddWithValue("@.GI_TB_City", GI_TB_City.Text);

cmd.Parameters.AddWithValue("@.GI_DDL_State", GI_DDL_State.SelectedValue);

cmd.Parameters.AddWithValue("@.GI_TB_Zip", GI_TB_Zip.Text);

cmd.Parameters.AddWithValue("@.GI_TB_TradeName", GI_TB_TradeName.Text);

cmd.Parameters.AddWithValue("@.GI_TB_BillAddress", GI_TB_BillAddress.Text);

cmd.Parameters.AddWithValue("@.GI_TB_BillCity", GI_TB_BillCity.Text);

cmd.Parameters.AddWithValue("@.GI_DDL_BillState", GI_DDL_BillState.SelectedValue);

cmd.Parameters.AddWithValue("@.GI_TB_BillZip", GI_TB_BillZip.Text);

cmd.Parameters.AddWithValue("@.GI_TB_ContName", GI_TB_ContName.Text);

cmd.Parameters.AddWithValue("@.GI_TB_Title", GI_TB_Title.Text);

cmd.Parameters.AddWithValue("@.GI_TB_MobilePager", GI_TB_MobilePager.Text);

cmd.Parameters.AddWithValue("@.GI_TB_Email", GI_TB_Email.Text);

cmd.Parameters.AddWithValue("@.GI_TB_Fax", GI_TB_Fax.Text);

cmd.Parameters.AddWithValue("@.GI_TB_BusDesc", GI_TB_BusDesc.Text);

cmd.Parameters.AddWithValue("@.GI_TB_BusStartDate", GI_TB_BusStartDate.Text);

cmd.Parameters.AddWithValue("@.GI_TB_BusPhone", GI_TB_BusPhone.Text);

cmd.Parameters.AddWithValue("@.GI_RB_PuchOrdsReq", GI_RB_PuchOrdsReq.SelectedValue);

cmd.Parameters.AddWithValue("@.GI_RB_BusType", GI_RB_BusType.SelectedValue);

cmd.Parameters.AddWithValue("@.GI_RB_LiensJudges", GI_RB_LiensJudges.SelectedValue);

cmd.Parameters.AddWithValue("@.GI_RB_TaxExempt", GI_RB_TaxExempt.SelectedValue);

cmd.Parameters.AddWithValue("@.GI_TB_FedIDNO", GI_TB_FedIDNO.Text);

cmd.Parameters.AddWithValue("@.GI_RB_PriorBankrupt", GI_RB_PriorBankrupt.SelectedValue);

cmd.Parameters.AddWithValue("@.GI_TB_PriorBankr", GI_TB_PriorBankr.Text);

cmd.Parameters.AddWithValue("@.BFR_TB_ContPhone", BFR_TB_ContPhone.Text);

cmd.Parameters.AddWithValue("@.BFR_TB_AcctNum1", BFR_TB_AcctNum1.Text);

cmd.Parameters.AddWithValue("@.BFR_TB_AcctNum2", BFR_TB_AcctNum2.Text);

cmd.Parameters.AddWithValue("@.BFR_TB_CurrBal1", BFR_TB_CurrBal1.Text);

cmd.Parameters.AddWithValue("@.BFR_TB_CurrBal2", BFR_TB_CurrBal2.Text);

cmd.Parameters.AddWithValue("@.BFR_TB_CurrBal3", BFR_TB_CurrBal3.Text);

cmd.Parameters.AddWithValue("@.BFR_TB_CurrBal4", BFR_TB_CurrBal4.Text);

cmd.Parameters.AddWithValue("@.BFR_RB_AcctType", BFR_RB_AcctType.Text);

cmd.Parameters.AddWithValue("@.TR_TB_ContName1", TR_TB_ContName1.Text);

cmd.Parameters.AddWithValue("@.TR_TB_ContAddr1", TR_TB_ContAddr1.Text);

cmd.Parameters.AddWithValue("@.TR_TB_ContCity1", TR_TB_ContCity1.Text);

cmd.Parameters.AddWithValue("@.TR_DDL_ContSt1", TR_DDL_ContSt1.SelectedValue);

cmd.Parameters.AddWithValue("@.TR_TB_ContZip1", TR_TB_ContZip1.Text);

cmd.Parameters.AddWithValue("@.TR_TB_ContPhone1", TR_TB_ContPhone1.Text);

cmd.Parameters.AddWithValue("@.TR_TB_Cont_Acct1", TR_TB_Cont_Acct1.Text);

cmd.Parameters.AddWithValue("@.TR_TB_ContName2", TR_TB_ContName2.Text);

cmd.Parameters.AddWithValue("@.TR_TB_ContAddr2", TR_TB_ContAddr2.Text);

cmd.Parameters.AddWithValue("@.TR_TB_ContCity2", TR_TB_ContCity2.Text);

cmd.Parameters.AddWithValue("@.TR_DDL_ContSt2", TR_DDL_ContSt2.SelectedValue);

cmd.Parameters.AddWithValue("@.TR_TB_ContZip2", TR_TB_ContZip2.Text);

cmd.Parameters.AddWithValue("@.TR_TB_ContPhone2", TR_TB_ContPhone2.Text);

cmd.Parameters.AddWithValue("@.TR_TB_Cont_Acct2", TR_TB_Cont_Acct2.Text);

cmd.Parameters.AddWithValue("@.TR_TB_ContName3", TR_TB_ContName3.Text);

cmd.Parameters.AddWithValue("@.TR_TB_ContAddr3", TR_TB_ContAddr3.Text);

cmd.Parameters.AddWithValue("@.TR_TB_ContCity3", TR_TB_ContCity3.Text);

cmd.Parameters.AddWithValue("@.TR_DDL_ContSt3", TR_DDL_ContSt3.SelectedValue);

cmd.Parameters.AddWithValue("@.TR_TB_ContZip3", TR_TB_ContZip3.Text);

cmd.Parameters.AddWithValue("@.TR_TB_ContPhone3", TR_TB_ContPhone3.Text);

cmd.Parameters.AddWithValue("@.TR_TB_Cont_Acct3", TR_TB_Cont_Acct3.Text);

cmd.Parameters.AddWithValue("@.PI_TB_Name1", PI_TB_Name1.Text);

cmd.Parameters.AddWithValue("@.PI_TB_HomeAddr1", PI_TB_HomeAddr1.Text);

cmd.Parameters.AddWithValue("@.PI_TB_BDay1", PI_TB_BDay1.Text);

cmd.Parameters.AddWithValue("@.PI_TB_SSNum1", PI_TB_SSNum1.Text);

cmd.Parameters.AddWithValue("@.PI_TB_HomePh1", PI_TB_HomePh1.Text);

cmd.Parameters.AddWithValue("@.PI_TB_PrcntOwn1", PI_TB_PrcntOwn1.Text);

cmd.Parameters.AddWithValue("@.PI_TB_NetWorth1", PI_TB_NetWorth1.Text);

cmd.Parameters.AddWithValue("@.PI_TB_AnnInc1", PI_TB_AnnInc1.Text);

cmd.Parameters.AddWithValue("@.PI_TB_MonHouPay1", PI_TB_MonHouPay1.Text);

cmd.Parameters.AddWithValue("@.PI_TB_Name2", PI_TB_Name2.Text);

cmd.Parameters.AddWithValue("@.PI_TB_HomeAddr2", PI_TB_HomeAddr2.Text);

cmd.Parameters.AddWithValue("@.PI_TB_BDay2", PI_TB_BDay2.Text);

cmd.Parameters.AddWithValue("@.PI_TB_SSNum2", PI_TB_SSNum2.Text);

cmd.Parameters.AddWithValue("@.PI_TB_HomePh2", PI_TB_HomePh2.Text);

cmd.Parameters.AddWithValue("@.PI_TB_PrcntOwn2", PI_TB_PrcntOwn2.Text);

cmd.Parameters.AddWithValue("@.PI_TB_NetWorth2", PI_TB_NetWorth2.Text);

cmd.Parameters.AddWithValue("@.PI_TB_AnnInc2", PI_TB_AnnInc2.Text);

cmd.Parameters.AddWithValue("@.PI_TB_MonHouPay2", PI_TB_MonHouPay2.Text);

cmd.Parameters.AddWithValue("@.PI_TB_Name3", PI_TB_Name3.Text);

cmd.Parameters.AddWithValue("@.PI_TB_HomeAddr3", PI_TB_HomeAddr3.Text);

cmd.Parameters.AddWithValue("@.PI_TB_BDay3", PI_TB_BDay3.Text);

cmd.Parameters.AddWithValue("@.PI_TB_SSNum3", PI_TB_SSNum3.Text);

cmd.Parameters.AddWithValue("@.PI_TB_HomePh3", PI_TB_HomePh3.Text);

cmd.Parameters.AddWithValue("@.PI_TB_PrcntOwn3", PI_TB_PrcntOwn3.Text);

cmd.Parameters.AddWithValue("@.PI_TB_NetWorth3", PI_TB_NetWorth3.Text);

cmd.Parameters.AddWithValue("@.PI_TB_AnnInc3", PI_TB_AnnInc3.Text);

cmd.Parameters.AddWithValue("@.PI_TB_MonHouPay3", PI_TB_MonHouPay3.Text);

cmd.Connection = connection;

cmd.Connection.Open();

string NewID = cmd.ExecuteScalar().ToString();

cmd.Connection.Close();

Response.Redirect("DisplayCredApp.aspx?ID=" + Request["NewID"]);

}

catch (Exception ex)

{

lblMessage.Text ="ERROR: " + ex.Message;lblMessage.Visible =true;

}

}

}

this seems to be ok... but i get a load of errors on my "read/display" page which looks like the folowing... (this is the code behind, again, written in C#)

using System;

using System.Data;

using System.Data.SqlClient;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

publicpartialclassVinny_Credit_Application_DisplayCredApp : System.Web.UI.Page

{

protectedvoid Page_Load(object sender,EventArgs e)

{

if (!IsPostBack && Response["NewID"] !=null)

{

string ConnectionString =ConfigurationManager.ConnectionStrings["ws2dbConnectionString"].ConnectionString;

SqlConnection connection =newSqlConnection(ConnectionString);

SqlCommand cmd =newSqlCommand(@."SELECT * FROM CreditAppFile WHERE ID = @.ID", connection);cmd.Parameters.Add("@.ID", Response["NewID"].ToString());

connection.Open();

SqlDataReader reader = cmd.ExecuteReader();

reader.Read();

GI_RB_Div.Text = reader["GI_RB_Div"].ToString();

GI_RB_ExistCust.Text = reader["GI_RB_ExistCust"].ToString();

GI_TB_LegalFirmName.Text = reader["GI_TB_LegalFirmName"].ToString();

GI_TB_Address.Text = reader["GI_TB_Address"].ToString();

GI_TB_City.Text = reader["GI_TB_City"].ToString();

GI_DDL_State.Text = reader["GI_DDL_State"].ToString();

GI_TB_Zip.Text = reader["GI_TB_Zip"].ToString();

GI_TB_TradeName.Text = reader["GI_TB_TradeName"].ToString();

GI_TB_BillAddress.Text = reader["GI_TB_BillAddress"].ToString();

GI_TB_BillCity.Text = reader["GI_TB_BillCity"].ToString();

GI_DDL_BillState.Text = reader["GI_DDL_BillState"].ToString();

GI_TB_BillZip.Text = reader["GI_TB_BillZip"].ToString();

GI_TB_ContName.Text = reader["GI_TB_ContName"].ToString();

GI_TB_Title.Text = reader["GI_TB_Title"].ToString();

GI_TB_MobilePager.Text = reader["GI_TB_MobilePager"].ToString();

GI_TB_Email.Text = reader["GI_TB_Email"].ToString();

GI_TB_Fax.Text = reader["GI_TB_Fax"].ToString();

GI_TB_BusDesc.Text = reader["GI_TB_BusDesc"].ToString();

GI_TB_BusStartDate.Text = reader["GI_TB_BusStartDate"].ToString();

GI_TB_BusPhone.Text = reader["GI_TB_BusPhone"].ToString();

GI_RB_PuchOrdsReq.Text = reader["GI_RB_PuchOrdsReq"].ToString();

GI_RB_BusType.Text = reader["GI_RB_BusType"].ToString();

GI_RB_LiensJudges.Text = reader["GI_RB_LiensJudges"].ToString();

GI_RB_TaxExempt.Text = reader["GI_RB_TaxExempt"].ToString();

GI_TB_FedIDNO.Text = reader["GI_TB_FedIDNO"].ToString();

GI_RB_PriorBankrupt.Text = reader["GI_RB_PriorBankrupt"].ToString();

GI_TB_PriorBankr.Text = reader["GI_TB_PriorBankr"].ToString();

BFR_TB_ContPhone.Text = reader["BFR_TB_ContPhone"].ToString();

BFR_TB_AcctNum1.Text = reader["BFR_TB_AcctNum1"].ToString();

BFR_TB_AcctNum2.Text = reader["BFR_TB_AcctNum2"].ToString();

BFR_TB_CurrBal1.Text = reader["BFR_TB_CurrBal1"].ToString();

BFR_TB_CurrBal2.Text = reader["BFR_TB_CurrBal2"].ToString();

BFR_TB_CurrBal3.Text = reader["BFR_TB_CurrBal3"].ToString();

BFR_TB_CurrBal4.Text = reader["BFR_TB_CurrBal4"].ToString();

BFR_RB_AcctType.Text = reader["BFR_RB_AcctType"].ToString();

TR_TB_ContName1.Text = reader["TR_TB_ContName1"].ToString();

TR_TB_ContAddr1.Text = reader["TR_TB_ContAddr1"].ToString();

TR_TB_ContCity1.Text = reader["TR_TB_ContCity1"].ToString();

TR_DDL_ContSt1.Text = reader["TR_DDL_ContSt1"].ToString();

TR_TB_ContZip1.Text = reader["TR_TB_ContZip1"].ToString();

TR_TB_ContPhone1.Text = reader["TR_TB_ContPhone1"].ToString();

TR_TB_Cont_Acct1.Text = reader["TR_TB_Cont_Acct1"].ToString();

TR_TB_ContName2.Text = reader["TR_TB_ContName2"].ToString();

TR_TB_ContAddr2.Text = reader["TR_TB_ContAddr2"].ToString();

TR_TB_ContCity2.Text = reader["TR_TB_ContCity2"].ToString();

TR_DDL_ContSt2.Text = reader["TR_DDL_ContSt2"].ToString();

TR_TB_ContZip2.Text = reader["TR_TB_ContZip2"].ToString();

TR_TB_ContPhone2.Text = reader["TR_TB_ContPhone2"].ToString();

TR_TB_Cont_Acct2.Text = reader["TR_TB_Cont_Acct2"].ToString();

TR_TB_ContName3.Text = reader["TR_TB_ContName3"].ToString();

TR_TB_ContAddr3.Text = reader["TR_TB_ContAddr3"].ToString();

TR_TB_ContCity3.Text = reader["TR_TB_ContCity3"].ToString();

TR_DDL_ContSt3.Text = reader["TR_DDL_ContSt3"].ToString();

TR_TB_ContZip3.Text = reader["TR_TB_ContZip3"].ToString();

TR_TB_ContPhone3.Text = reader["TR_TB_ContPhone3"].ToString();

TR_TB_Cont_Acct3.Text = reader["TR_TB_Cont_Acct3"].ToString();

PI_TB_Name1.Text = reader["PI_TB_Name1"].ToString();

PI_TB_HomeAddr1.Text = reader["PI_TB_HomeAddr1"].ToString();

PI_TB_BDay1.Text = reader["PI_TB_BDay1"].ToString();

PI_TB_SSNum1.Text = reader["PI_TB_SSNum1"].ToString();

PI_TB_HomePh1.Text = reader["PI_TB_HomePh1"].ToString();

PI_TB_PrcntOwn1.Text = reader["PI_TB_PrcntOwn1"].ToString();

PI_TB_NetWorth1.Text = reader["PI_TB_NetWorth1"].ToString();

PI_TB_AnnInc1.Text = reader["PI_TB_AnnInc1"].ToString();

PI_TB_MonHouPay1.Text = reader["PI_TB_MonHouPay1"].ToString();

PI_TB_Name2.Text = reader["PI_TB_Name2"].ToString();

PI_TB_HomeAddr2.Text = reader["PI_TB_HomeAddr2"].ToString();

PI_TB_BDay2.Text = reader["PI_TB_BDay2"].ToString();

PI_TB_SSNum2.Text = reader["PI_TB_SSNum2"].ToString();

PI_TB_HomePh2.Text = reader["PI_TB_HomePh2"].ToString();

PI_TB_PrcntOwn2.Text = reader["PI_TB_PrcntOwn2"].ToString();

PI_TB_NetWorth2.Text = reader["PI_TB_NetWorth2"].ToString();

PI_TB_AnnInc2.Text = reader["PI_TB_AnnInc2"].ToString();

PI_TB_Name2.Text = reader["PI_TB_MonHouPay2"].ToString();

PI_TB_Name3.Text = reader["PI_TB_Name3"].ToString();

PI_TB_HomeAddr3.Text = reader["PI_TB_HomeAddr3"].ToString();

PI_TB_BDay3.Text = reader["PI_TB_BDay3"].ToString();

PI_TB_SSNum3.Text = reader["PI_TB_SSNum3"].ToString();

PI_TB_HomePh3.Text = reader["PI_TB_HomePh3"].ToString();

PI_TB_PrcntOwn3.Text = reader["PI_TB_PrcntOwn3"].ToString();

PI_TB_NetWorth3.Text = reader["PI_TB_NetWorth3"].ToString();

PI_TB_AnnInc3.Text = reader["PI_TB_AnnInc3"].ToString();PI_TB_MonHouPay3.Text = reader["PI_TB_MonHouPay3"].ToString();

connection.Close();

}

}

}

been working on this for days... everytime i get a little closer i seem to get that much farther away... if you can help by all means give me what you got...

thanks for all the help in advance!!!!

- Vinny

Hi Vinny,

Thats alot of columns in that table. Anyway what is the error message you are getting. It would help to know where it stops.

|||

VinnyPip:

string NewID = cmd.ExecuteScalar().ToString();

cmd.Connection.Close();

Response.Redirect("DisplayCredApp.aspx?ID=" + Request["NewID"]);

.

.

.

SqlCommand cmd =newSqlCommand(@."SELECT * FROM CreditAppFile WHERE ID = @.ID", connection);cmd.Parameters.Add("@.ID", Response["NewID"].ToString());

Change

Response.Redirect("DisplayCredApp.aspx?ID=" + Request["NewID"]);

to

Response.Redirect("DisplayCredApp.aspx?ID=" +NewID);

Change

SqlCommand cmd =newSqlCommand(@."SELECT * FROM CreditAppFile WHERE ID = @.ID", connection);cmd.Parameters.Add("@.ID", Response["NewID"].ToString());

to

SqlCommand cmd =newSqlCommand(@."SELECT * FROM CreditAppFile WHERE ID = @.ID", connection);cmd.Parameters.Add("@.ID", Request.QueryString["NewID"]);

|||

made the above changes Mike suggested and the main error is still the same...

Description:An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message:CS0021: Cannot apply indexing with [] to an expression of type 'System.Web.HttpResponse'

Source Error:

Line 15: protected void Page_Load(object sender, EventArgs e)Line 16: {Line 17: if (!IsPostBack && Response["NewID"] != null)Line 18: {Line 19: string ConnectionString = ConfigurationManager.ConnectionStrings["ws2dbConnectionString"].ConnectionString;

|||

Damn. Missed that one. Change it to

if (!IsPostBack && Request.QueryString["ID"] != null)

And - where I changed something to Request,QueryString["NewID"] before (in the parameters), change that to

Request.QueryString["ID"]
|||

that seemed to compile ok...

and for my next trick... uhh... i mean error:

Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:System.InvalidOperationException: Invalid attempt to read when no data is present.

Source Error:

Line 29: reader.Read();Line 30:Line 31: GI_RB_Div.Text = reader["GI_RB_Div"].ToString();Line 32: GI_RB_ExistCust.Text = reader["GI_RB_ExistCust"].ToString();Line 33: GI_TB_LegalFirmName.Text = reader["GI_TB_LegalFirmName"].ToString();


keep em comin' mike... really appreciate this!!!

|||

NEVERMIND MIKE!!!!!!!!

IT WORKS!!!!!!

next time you're in NYC the drinks are on me... thanks a ton!!!

|||That suggests there is no data. Check the value of ID in the querystring of the page to make sure it was passed correctly (no spaces or odd urlencoded chars), then try running the query in SSMS to see that it works.

Saturday, February 25, 2012

Nearest-neighbour logic - please help!

Hi,
Hope you can help me with this one. I'm building a search engine with
a SQL Server 2000 box in the backend. If a user gets no result for some
search but there is a close match - I want that match to be suggested
(or any others).
Now I believe that the technology to use is called: "Ternary Search
Trees" (due to a fast implementation of the Levenshtein Distance
algorithm). However in SQL Server 2000 the equivalent to sue is called
"indexed views".
My question is am I right? Can anyone out there give me a few pointers
i nthe right directions please? Any comments/suggestions/help greatly
appreciated...
Cheers,
Al.Hi,
Indexed views would have nothing in particular to do with advanced search
algorithms.
You may wish to investigate the SOUNDEX and associated functions. See Books
Online.
Thank you,
Daniel Jameson
SQL Server DBA
Children's Oncology Group
www.childrensoncologygroup.org
<almurph@.altavista.com> wrote in message
news:1163420393.594947.317930@.k70g2000cwa.googlegroups.com...
> Hi,
>
> Hope you can help me with this one. I'm building a search engine with
> a SQL Server 2000 box in the backend. If a user gets no result for some
> search but there is a close match - I want that match to be suggested
> (or any others).
> Now I believe that the technology to use is called: "Ternary Search
> Trees" (due to a fast implementation of the Levenshtein Distance
> algorithm). However in SQL Server 2000 the equivalent to sue is called
> "indexed views".
> My question is am I right? Can anyone out there give me a few pointers
> i nthe right directions please? Any comments/suggestions/help greatly
> appreciated...
> Cheers,
> Al.
>

Nearest-neighbour logic - please help!

Hi,
Hope you can help me with this one. I'm building a search engine with
a SQL Server 2000 box in the backend. If a user gets no result for some
search but there is a close match - I want that match to be suggested
(or any others).
Now I believe that the technology to use is called: "Ternary Search
Trees" (due to a fast implementation of the Levenshtein Distance
algorithm). However in SQL Server 2000 the equivalent to sue is called
"indexed views".
My question is am I right? Can anyone out there give me a few pointers
i nthe right directions please? Any comments/suggestions/help greatly
appreciated...
Cheers,
Al.Hi,
Indexed views would have nothing in particular to do with advanced search
algorithms.
You may wish to investigate the SOUNDEX and associated functions. See Books
Online.
--
Thank you,
Daniel Jameson
SQL Server DBA
Children's Oncology Group
www.childrensoncologygroup.org
<almurph@.altavista.com> wrote in message
news:1163420393.594947.317930@.k70g2000cwa.googlegroups.com...
> Hi,
>
> Hope you can help me with this one. I'm building a search engine with
> a SQL Server 2000 box in the backend. If a user gets no result for some
> search but there is a close match - I want that match to be suggested
> (or any others).
> Now I believe that the technology to use is called: "Ternary Search
> Trees" (due to a fast implementation of the Levenshtein Distance
> algorithm). However in SQL Server 2000 the equivalent to sue is called
> "indexed views".
> My question is am I right? Can anyone out there give me a few pointers
> i nthe right directions please? Any comments/suggestions/help greatly
> appreciated...
> Cheers,
> Al.
>

Nearest-neighbour logic - please help!

Hi,
Hope you can help me with this one. I'm building a search engine with
a SQL Server 2000 box in the backend. If a user gets no result for some
search but there is a close match - I want that match to be suggested
(or any others).
Now I believe that the technology to use is called: "Ternary Search
Trees" (due to a fast implementation of the Levenshtein Distance
algorithm). However in SQL Server 2000 the equivalent to sue is called
"indexed views".
My question is am I right? Can anyone out there give me a few pointers
i nthe right directions please? Any comments/suggestions/help greatly
appreciated...
Cheers,
Al.
Hi,
Indexed views would have nothing in particular to do with advanced search
algorithms.
You may wish to investigate the SOUNDEX and associated functions. See Books
Online.
Thank you,
Daniel Jameson
SQL Server DBA
Children's Oncology Group
www.childrensoncologygroup.org
<almurph@.altavista.com> wrote in message
news:1163420393.594947.317930@.k70g2000cwa.googlegr oups.com...
> Hi,
>
> Hope you can help me with this one. I'm building a search engine with
> a SQL Server 2000 box in the backend. If a user gets no result for some
> search but there is a close match - I want that match to be suggested
> (or any others).
> Now I believe that the technology to use is called: "Ternary Search
> Trees" (due to a fast implementation of the Levenshtein Distance
> algorithm). However in SQL Server 2000 the equivalent to sue is called
> "indexed views".
> My question is am I right? Can anyone out there give me a few pointers
> i nthe right directions please? Any comments/suggestions/help greatly
> appreciated...
> Cheers,
> Al.
>

Monday, February 20, 2012

Navigationbar when using http://servername/ReportServer/...

I have a button insida an application that fire up Explorer and send the user to http://servername/ReportServer/myreport......&MyParameter=AValue

I read that the ReportServer path was required instead of Reports in case parameters were sent in the URL. But when I use this path (ReportServer) I don't get the navigationbar at the top (with home, My Subscriptions, My Settings etc).

Is there any way of sending parameters via the URL and still have the navigationbar at the top?

regards

Andreas

Do you understand my question or should I be more specific?

regards Andreas