|
Thanks for your Advice
Now the Second Option,can work for me. But i have a Question regarding the replace part.
The "YourDataBaseName" does it matter if it comes from a Session variable ?
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
www.ITS.co.za
|
|
|
|
|
Vuyiswa Maseko wrote: The "YourDataBaseName" does it matter if it comes from a Session variable ?
Nope.
As long as it's a string!
var question = (_2b || !(_2b));
|
|
|
|
|
hi Greg
i Done it this way
<connectionStrings>
<add name="string1" connectionString="datasource=VUYISWA_SERVER ;User ID=VA;password=MASEKO;Database=NEWDT" providerName="System.Data.SqlClient" />
</connectionStrings>
And the C# code is like this
public void UpdateConfig()
{
String StrDatabase;
if (Session["ActiveDatabase"] != null)
{
StrDatabase = Convert.ToString(Session["ActiveDatabase"]);
string connString = ConfigurationManager.ConnectionStrings["string1"].ConnectionString;
connString = connString.Replace("NEWDT", StrDatabase);
}
else
{
StrDatabase = "oDirectv3";
string connString = ConfigurationManager.ConnectionStrings["string1"].ConnectionString;
connString = connString.Replace("NEWDT", StrDatabase);
}
}
And am Calling this Function like this from a page load
protected void Page_Load(object sender, EventArgs e)
{
Session["ActiveDatabase"] = "Mafutha";
UpdateConfig();
Response.Write("<script> alert('Wow i did it');</script>");
}
Remember this is just a test to see if it will change the Database in the Connection String. After i run it i get the alert no Errors but the Connection String has not been changed to "Mafutha".
What could be the Problem ?
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
www.ITS.co.za
|
|
|
|
|
OK, now look.
Obviously, your UpdateConfig() method is not going to physically alter the web.config.
The connection string you want to use is only going to work with just one session, and that's a good thing. Instead of keeping just the database name in your session variable, store the whole connection string.
If you do not want to, change your UpdateConfig() method (and change its name too, cos it's confusing) like so:
private string GetConnectionString(string DB)
{
string connString = ConfigurationManager.ConnectionStrings["string1"].ConnectionString;
if (Session["ActiveDatabase"] != null)
{
return connString.Replace("NEWDT", DB);
}
else
{
return connString.Replace("NEWDT", "oDirectv3");
}
}
Anytime you want to use the connection string, just call this function to return it to you.
var question = (_2b || !(_2b));
|
|
|
|
|
Good Day Greg
I would like to take this chance and thank you for what you have doe for me. Everything is Working Fine.
Thank you
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
www.ITS.co.za
|
|
|
|
|
Hi friends,
I got a question that
"Can i use my own SQl Databse Table named 'RegisteredUsers' to store the information about users who wants to register on my site. If i used my own class like such without using the ASPMembershipProvider then is there any drawback of using my method."
As i have this table "Registered Users" and its class that will handle all the information about the user.
Thanks in advance if any one can answer.
Cause i m confused about my using wether my own structures, Methods and classes OR just to use the ASPMembershipProvider for the user login and registration.
|
|
|
|
|
Yes ... no problem with that ... We generally use own custom database for Registered user and dont use ASPMembershipProviders.
Rather it is better to create a Web Interface for login, probably you can use Web service for login if you want
|
|
|
|
|
I got this error during debugging the code without using an IIS or webserver. I got two errors ,
1.
Line 105:<compilers>
Line 106:<compiler language="c#;cs;csharp" extension=".cs" warninglevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
Line 107:<provideroption name="CompilerVersion" value="v3.5">
Line 108:<provideroption name="WarnAsError" value="false">
Line 109:
--the bolded session will have the error.
2. child notes not allowed.
Help me please!
|
|
|
|
|
Really you have not Specified your Problem.
Tell us what were you trying to do before the Error occurred. and post us the Error the way it appears
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
www.ITS.co.za
|
|
|
|
|
Currently I need to write a code To Import data from Excel sheet to sql Database-asp.net 2.0
I Have Written A function For It
Function Is Given Below ;
But as i execute it it gives Error Meaasge
"The Microsoft Jet database engine cannot open the file 'D:\'. It is already opened exclusively by another user, or you need permission to view its data."
I Have Order.xls File In D Drive
protected void btnUpload_Click1(object sender, EventArgs e)
{
string PathtoTextFile = ("D:\\");
Response.Write(PathtoTextFile);
System.Data.OleDb.OleDbConnection oCon = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\;Extended Properties= \"Excel 8.0;HDR=no;IMEX=1 \"");
System.Data.OleDb.OleDbDataAdapter oCmd = new System.Data.OleDb.OleDbDataAdapter("select * from Order.xls", oCon);
DataSet myDS = new DataSet();
oCmd.Fill(myDS);
oCon.Close();
}
Raghvendra
|
|
|
|
|
You need to pass the filename in the data source, in the connection string, dude.
You're on the right path, though.
And then, the sql you wrote ("select * from Order.xls") should really be ("select * from Sheet1"), or whatever your Sheet is called in that excel spreadsheet.
The rest seems fine... Except I would use a DataTable, and not a DataSet.
Easier that way
var question = (_2b || !(_2b));
|
|
|
|
|
Thanks For Reply,
I did the same as u instructed ,
But Still Having Same Error
Raghvendra
|
|
|
|
|
I declare a variable in one method and used it. Now i want to access the variable from another method. Can anyone say how to acheive this?
|
|
|
|
|
Variable within the method is private for that method. if you want to access one variable in more than one mthod, declase as private/public in the class.
The miracle is this--the more we share, the more we have.
|
|
|
|
|
|
public string abc;
public void function function1()
{
abc="anything";
}
public void function function2()
{
string def =abc;
}
function1();
function2();
or you can also pass it as a parameter...
umerumerumer
|
|
|
|
|
Hi all,
Can anybody tell how to export data from datagrid to .mdb format(i.e into Access format).If possible please let me know the code.
thanks
Murali
|
|
|
|
|
Read up on the JET engine, please.
And stop posting the same question over and over again.
The JET engine will allow you to create a new ACCESS database (among other formats) and populate it with whatever you want. It is really easy to use, but:
you haven't posted a single line of code. Don't assume people are waiting to write stuff for you, look it up yourself! And even if they do, how can anybody assume, what you get will be comprehensible by you.
Good luck in your research.
var question = (_2b || !(_2b));
|
|
|
|
|
whgen i load one page i got this error on post back
the state information is invalid for this page and might be corrupted.
N!dh!
|
|
|
|
|
|
Hi,
I have already gone through all these but couldn't find solution so i pst it here.
N!dh!
|
|
|
|
|
|
Hi in my folder i have a file...,
That fiel name is file1.doc...,
now i have to upload a file...,
the file have to save on that existing same file name...,
mean suppose if i upload the test.doc the file have to save as file1.doc...,
how to do this?,
Thanks & Regards,
Member 3879881,
please don't forget to vote on the post
|
|
|
|
|
Just Check if it exists, if it does, delete it else save
if(System.IO.File.Exists(strPath))
{
System.IO.File.Delete(strPath);
}
else
{
}
Hope it Helps
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
www.ITS.co.za
|
|
|
|
|
Hi guys in my accordion control content template i bind repeater control...,
now i like to do paging concept in my link button which is in inside the accordion control...,
i have tp pass 4 parameters to my repeater bind method...,
those are my repeaterid, hiden value amd that two linkbutton id's,
then only i can bind my repaeater...,
now in my paging link button how can i find this control ids and pass to my repeaterbind method?
Thanks & Regards,
Member 3879881,
please don't forget to vote on the post
|
|
|
|