Showing posts with label pls. Show all posts
Showing posts with label pls. Show all posts

Tuesday, March 27, 2012

correct me??

I've created C#.net program (behind code style).

when I run it in Internet explorer, the following error occurs in IE window.

pls instruct me how to handle and correct this error.

And how to initialize the connectionstring... Great thank!

Server Error in '/' Application.


------------------------

The ConnectionString property has not been initialized.
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: The ConnectionString property has not been initialized.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:


[InvalidOperationException: The ConnectionString property has not been initialized.]
System.Data.SqlClient.SqlConnection.Open() +809
CodeBox.BehindCode.getSubject() +80
CodeBox.BehindCode.Page_Load(Object sender, EventArgs e) +31
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +29
System.Web.UI.Page.ProcessRequestMain() +724

------------------------

Version Information: Microsoft .NET Framework Version:1.0.3705.0; ASP.NET Version:1.0.3705.0

Hi,
You haven't posted the code that you are trying to execute.
From the error, it seems that you havent set the connection string property for your connection object.
You can initialize the connection string as follows:-
SqlConnection objCon = new SqlConnection("put your connection string here");
Thanks.|||if you still have the problem show us the code !!|||

hi! thanks...
but I still have problem...
I want to show you my code and error message...
here is my code...
SqlDataReader getSubject(){
//create instance of connection and command object

//SqlConnection myconnection=new SqlConnection(ConfigurationSettings.AppSettings["connectionString"]);
constring ="DSN=fisca;User ID=sa;Password=admin;";
SqlConnection myconnection = new SqlConnection(constring);

SqlCommand mycommand=new SqlCommand("select * from Subject",myconnection);
//open the database connection and execute the command
myconnection.Open();
SqlDataReader result=mycommand.ExecuteReader(CommandBehavior.CloseConnection);
return result;
}

here is error message. I sure that dsn is really existing and userid, password of sql server is true....
and I also sure that variable constring is declared.

Server Error in '/' Application.

Unknown connection option in connection string: dsn.

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.ArgumentException: Unknown connection option in connection string: dsn.
Source Error:
Line 77: //SqlConnection myconnection=new SqlConnection(ConfigurationSettings.AppSettings["connectionString"]);Line 78: constring ="DSN=fisca;User ID=sa;Password=admin;";Line 79: SqlConnection myconnection = new SqlConnection(constring);Line 80: Line 81: SqlCommand mycommand=new SqlCommand("select * from Subject",myconnection);

Source File:c:\inetpub\wwwroot\CourseRequisition.cs Line:79
Stack Trace:
[ArgumentException: Unknown connection option in connection string: dsn.] System.Data.SqlClient.ConStringUtil.ParseStringIntoHashtable(String conString, Hashtable values) +673 System.Data.SqlClient.ConStringUtil.ParseConnectionString(String connectionString) +55 System.Data.SqlClient.SqlConnection.set_ConnectionString(String value) +375 System.Data.SqlClient.SqlConnection..ctor(String connectionString) +164 CodeBox.BehindCode.getSubject() in c:\inetpub\wwwroot\CourseRequisition.cs:79 CodeBox.BehindCode.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\CourseRequisition.cs:36 System.Web.UI.Control.OnLoad(EventArgs e) +67 System.Web.UI.Control.LoadRecursive() +29 System.Web.UI.Page.ProcessRequestMain() +724


Version Information: Microsoft .NET Framework Version:1.0.3705.0; ASP.NET Version:1.0.3705.0|||

here is my code...

SqlDataReader getSubject(){
//create instance of connection and command object
SqlConnection myconnection=new SqlConnection(ConfigurationSettings.AppSettings["connectionString"]);
SqlCommand mycommand=new SqlCommand("select * from Subject",myconnection);
//open the database connection and execute the command
myconnection.Open();
SqlDataReader result=mycommand.ExecuteReader(CommandBehavior.CloseConnection);
return result;
}
but now I can find it out and I've corrected it myself.
cause I initialize connectionstring in web.config file. It can put away error.
so now I want to know that is there many ways to connect to sql server?...
how many way?
I just know two way,
1. Sqlconnection constring=new Sqlconnection("connection string");
2. SqlConnection myconnection=new SqlConnection(ConfigurationSettings.AppSettings["connectionString"]);
so pls let me know. cause I willingly want to know C#.net thoroughly.
I also learning it from book and creating C#.net application..
Have a bright and wonderful day!

|||the connection string that you provided is not correct !!!
look atwww.connstingSttings.com and see the proper contents of the connection string try to look the connetion string and if you still have problem get back to me

Sunday, February 19, 2012

Copy tables?

Hello!
Pls tell me how to copy a table (want to have another table with another
name, but has the same structure).
Thanks for your help!select * into NewTable from OldTable where 1 = 0
"Chi Pheo" <chipheo2k@.mail.ru> wrote in message
news:uRXezz1wEHA.3612@.tk2msftngp13.phx.gbl...
> Hello!
> Pls tell me how to copy a table (want to have another table with another
> name, but has the same structure).
> Thanks for your help!
>|||Problem with this solution is that it won't create any indexes or constraints.
You can use the Enterprise Manager Generate Script, change the name in the
script, and INSERT INTO new table FROM old table. Or use a Copy Object task
in DTS.
Sincerely,
Anthony Thomas
"John Ryan" wrote:
> select * into NewTable from OldTable where 1 = 0
> "Chi Pheo" <chipheo2k@.mail.ru> wrote in message
> news:uRXezz1wEHA.3612@.tk2msftngp13.phx.gbl...
> > Hello!
> > Pls tell me how to copy a table (want to have another table with another
> > name, but has the same structure).
> >
> > Thanks for your help!
> >
> >
>
>|||OK, thanks so much!
"AnthonyThomas" <AnthonyThomas@.discussions.microsoft.com> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ ×
ÎÏ×ÏÓÔÑÈ ÓÌÅÄÕÀÝÅÅ:
news:9E63270A-F95C-4605-82FE-ABA22859A7FC@.microsoft.com...
> Problem with this solution is that it won't create any indexes or
constraints.
> You can use the Enterprise Manager Generate Script, change the name in the
> script, and INSERT INTO new table FROM old table. Or use a Copy Object
task
> in DTS.
> Sincerely,
>
> Anthony Thomas
> "John Ryan" wrote:
> > select * into NewTable from OldTable where 1 = 0
> >
> > "Chi Pheo" <chipheo2k@.mail.ru> wrote in message
> > news:uRXezz1wEHA.3612@.tk2msftngp13.phx.gbl...
> > > Hello!
> > > Pls tell me how to copy a table (want to have another table with
another
> > > name, but has the same structure).
> > >
> > > Thanks for your help!
> > >
> > >
> >
> >
> >

Friday, February 17, 2012

Copy Table from another table

How to create a Table from another Table?
I need both structure and data ?

If any one know pls rply

bye
Smilemurali
murali@.gsdindia.com

Hi,
If your using SQLServer 2000 then you could use the DTS(Data Transformation Services). you could select your source database. And select the same database for its destination. When importing a copy of your table, you must rename it...

cheers,
Paul June A. Domag|||It's not clear whether you need Integration Services in this scenario. A 'SELECT... INTO' SQL statement might be sufficient. For more information, check books online.

regards,
ash|||If you're using Integration Service, you can use the transfer objects task. It will create the table and transfer the data it contains.|||The simplest method of all for doing this is to simply use the SELECT INTO statment. Here's how:

Suppose you're trying to copy the authors table of the Pubs SQL Server database with data and structure. To do so simply use this SQL script:

--
USE Pubs
GO

SELECT *
INTO copy_of_authors
FROM authors
GO
--

Executing this script will create a table named copy_of_authors containing all data from the authors table.

Regards,

Ejan

Monday, February 13, 2012

copy row within same table

Gud day guys...i have this problem of copying records within a table...pls help me

I have tried the code below but returned an error.......
"violation of PRIMARY or UNIQUE KEY constraint "INTEG_29" on table "SERVICE" "

Insert into Service (GroupNo,ServiceCode,ServiceName,SystemNo,Upload,timestampstr)
SELECT 6,ServiceCode,ServiceName,SystemNo,Upload,TIMESTAMPSTR
FROM Service
WHERE GroupNo=1

is this possible? pls help me with the sql statement to make this work......

note: timestampstr is the primary key with a not null value ...

Short answer: if timestampstr is your primary key, you need to have different values in there. I don't know what the definition of your timestampstr or what the semantics of its values are, so I can't tell you how to generate a unique value for it for the new rows.

HTH,

Mostafa Elhemali - SQL Engine

|||Its a datatype in Firebird which holds the timestamp value wherein date and time is stored = it is equivalent to datetime datatype in other languages...

my purpose in doing this is that i wanted to copy all records in a table(service) with groupno = 1 and insert in the same table changing only the groupno field in to 6 and all the other records are the same.....any alternative solution for this if primary doesnt allow the same value for a field? thanks.....|||you can not insert the value in the TimeStamp datatype explicitly, the Server will automatically insert the value into it when you do insert operation.