|
You say you tried, what did you try ? There are hundreds of samples online showing how to connect to a DB, we need to know what you tried, and what went wrong, to give you more focused help than you can get from a google search.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
Try this.
In Web.config file
<appSettings>
<add key="conn" value="Server=<ServerName>;Integrated Security=no;User ID=;PWD=;database=" />
</appSettings>
In Code-behind File
using System.Data.SqlClient;
string ConnectionString =System.Configuration.ConfigurationSettings.AppSettings["conn"];
SqlConnection Sconn=new SqlConnection(ConnectionString);
Sconn.Open();
-- modified at 3:42 Saturday 4th August, 2007
Regards,
Manowj
|
|
|
|
|
I'm guessing that may work if using the default DB on the same machine. Perhaps.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi shweta, well what i guess abou you is , u r new to this field.
may i ask u that r u working for noida branch.
well this is ur ans for connectivity.
string connect= "Server=Server_path;Database=ABC;User=user;Password=Password";
SqlConnection con = new SqlConnection(connect);
try it and make me know.
Hello Forum
Always be in touch to help about the topic ASP.NET
|
|
|
|
|
Why is your connection string not in resources ? Why do you create two connection objects in this code ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
plz look the code properly than question.
I have taken one connection object
and another a simple strin to pass on this object as credentials of server where to connected to.
Hello Forum
Always be in touch to help about the topic ASP.NET
|
|
|
|
|
OK, so long as you're asking
public SqlConnection con = new SqlConnection();
string connect= "Server=Server_path;Database=ABC;User=userassword=Password";
con = new SqlConnection(connect);
I assume that public means that con is a member variable. Otherwise, it's an error.
You create a new object at the point of declaring the variable.
You assign a string to the connection string, although you don't expose it in any way ( which is not wise )
Then you use this string to create a new connection object ( your second ), meaning that the first one is never used, and if this is a member variable, as it seems to be, it means that you have a member object, but you recreate it, every time you use it.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Also we can use our common sense while declaring the variables.
What i ans for the connectin doesnt mean that this is the exact and only ans for this post, its a Hint of doing.
And one who needs toimplement this can use its little mind according to its need.
For ur graet information i always use this as staic and defined under one class, so every time u have to declare the connection string.
Hello Forum
Always be in touch to help about the topic ASP.NET
|
|
|
|
|
sulabh2020 wrote: What i ans for the connectin doesnt mean that this is the exact and only ans for this post, its a Hint of doing.
OK, well, I pointed out some bad practises in your code, you rejected the claim. It seems that you accept it now ?
sulabh2020 wrote: so every time u have to declare the connection string.
It is always better to expose your connection string in a config file.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
sulabh2020 wrote: public SqlConnection con = new SqlConnection();
string connect= "Server=Server_path;Database=ABC;User=userassword=Password";
con = new SqlConnection(connect);
Looks bad design for me. con = new SqlConnection(connect); is not needed, using this line you are creating one more object for the SQLConnection class. SQlConnection object have a property ConnectionString . Instead of creating new connectiion assign value to this property. Or write connection initialization code after creating connectionstring.
|
|
|
|
|
Hi guys i have a value for example 23 now i display this like "000023.0" length shoulbe be 8. if i give 44.5 means it should display "000044.5", so lenght not exeed 8. please tell me how to display like this.
Praveen Kumar.R
|
|
|
|
|
Same as below - the Format method on the string class, or even the ToString on the int class, can be told what number format is needed.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
Try this
Format(<VariableName>,"000000.00") will give the result.
Regards,
Manowj
|
|
|
|
|
Hi guys i want displat the time like this format "06:12:12000000008" please let me know anybody know. how to write code
Praveen Kumar.R
|
|
|
|
|
Use the string's Format method to build the number in the format you need.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
hi,
i am trying to export the data from ASP.NEt datagrid to Xls file.
i am recieving this error :
Control 'dgBillsReviewed__ctl2__ctl0' of type 'DataGridLinkButton' must be placed inside a form tag with runat=server.
i am using HTMLtext writer to export the data. i am taking template columns in my grid. if i remove these template columns(when i drctly set the datasource, it is working fine)
please let me know the solution...
Thanks,
Rahi
If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
HI Rahi in ur HTML there is no Form tage so please put form tag and try again may be it will work if ur coding is correct.
Praveen Kumar.R
|
|
|
|
|
Hi,
Confirm that the datagrid is placed in between the <form> and </form>.
Regards,
Manowj
|
|
|
|
|
hi,
thanks for responding to my query.
my grid is placed in the Form Tag. still it is giving this error.
i am using Item Template to bind the data ...and i am using lables to display the grid data.
how to resolve this?? any idea??
Thanks,
Rahi
If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
why Session_End is fired after i deleted a folder using directory.delete(folderpath,true)
|
|
|
|
|
Hi,
This can be any one of the reasons.
(1). Given Session time might be expired.
(2). Time out because of slower response time
(3). Session got destroyed in any part of your code.
Check these.
Regards,
Manowj
|
|
|
|
|
Hi,
I am uploading multiple files from my web application. It is working fine on local pc. But when I am trying to upload file on server it gives erroe as "Illegal characters in path".
Can any one give me solution for this ??
Thanks!
|
|
|
|
|
Maybe U should use this
string path = Server.MapPath(@"~\Your_folder");
"@" means to escape backslash into string. And "~\" means that your files will upload into server folder.
Regard,
Edwin
|
|
|
|
|
if you're using Visual Studio to develop your ASP.Net applications, you may want to have a look at the extremely cool refactoring tools for ASP.Net just made available for free by Developer Express.
Have a look at see this blog entry and don't miss the link to the screencast!
More info can be seen (lots of screenshots) on this page from Mark Miller, the funny brains behind these productivity tools.
|
|
|
|
|
Woah, Thanx Cycnus, how do know about this coolest tool?
This is great!!!
Regard,
Edwin
|
|
|
|