Showing posts with label cant. Show all posts
Showing posts with label cant. Show all posts

Wednesday, March 28, 2012

substring value

hi..
i just cant set strat value to have a substring value..i.e...let suppose i have string a="asd,bsd,csd,dsd";
now i want to separate asd,bsd..using substring method.
pzl help me.Split could helps you

For info seString.Split Method

such a newbie that i cant even stand myself

so... here i am, 5 years of php/mysql programming and i feel like i'm learning from scratch... if anyone out there has a kind heart and a lot of patience... i reallly could use some help!

i'm to build an application in asp.net using SQL server db and have chosen c# style of programming as i am far better equipped to learn that syntax.

basically the only thing i have been able to do successfully is print the current time on the screen. i'm at quite a loss as to where to start...

the 1st issue is with the Web.config file -- I got it to show the error messages on the page but only if there is no other code but this: <customErrors mode="Off" />

once i add in <authentication mode="Forms" /> it makes the page act just like it did w/out the customErrors code giving me the whole runtime error msg telling me about customErrors"Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors..."

I think the real problems is- I don't even know where to start or the why's and what's... I have done some basic forms in asp but that isn't much like .net at all. Ican't even seem to get going since everything i try is giving me that Runtime Error message.. Even the full zipped up mini apps that i downloaded that are all ready to go give me errors.

Here are some of my more ignorant questions...

1. I'm using Dreamweaver to develop with. Would it be better to use Visual Web Developer? Would the time spent learning that new interface be made up for since it's built specifically w/ asp.net. I'm not a super dreamweaver developer anyway- i have always hand coded using Homesite but my current job wants me in dreamweaver so... Of course the visual web dev. express i downloaded - I can't even figure out how to change the defaultPageLanguage="VB" to be C#.

2. does anyone know of any sort of quick-start guide to what i need to know? it seems like there are several options of coding styles but i'm afraid i might be mixing them together and getting errors. i would like very much to just find a straight forward guide of one style.

honestly, i have been on the web all day reading, testing... if my co-workers weren't still here, i may actually start to cry... i know enough about web development that if i can just get over this really brainless spot i'm in, i'll hit the ground running!!

For question #1, I'd say a definite yes, but that's just my opinion. About 60% of all problems that I've helped people with are because they're not using Visual Studio to code with (probably more in fact). VS is not that hard to learn, and does so much of the grunt work for you.

For Question #2, the tutorial here is not badhttp://www.asp.net/QuickStart/aspnet/Default.aspx I would highly recommend going through it step by step. Also there are some excellent books on the subject (Dino Esposito's comes to mind). And, of course, there's a lot of help available here once you get going.

NC...


dzr wrote:

1. I'm using Dreamweaver to develop with. Would it be better to use Visual Web Developer? Would the time spent learning that new interface be made up for since it's built specifically w/ asp.net. I'm not a super dreamweaver developer anyway- i have always hand coded using Homesite but my current job wants me in dreamweaver so...

Ditch Dreamweaver.... you are missing out on one HUGE aid in helping you learn: Intellisense

dzr wrote:

Of course the visual web dev. express i downloaded - I can't even figure out how to change the default Page Language="VB" to be C#.

When you create the page it'll give you a dropdown for C# or VB

dzr wrote:

2. does anyone know of any sort of quick-start guide to what i need to know?

Right at the top of this very page: "Tutorials"


OK! Now I'm rolling... sorta... I did a few step by step tutorials andI have a grip on the site creation, basic interface and I haveconnected to my database!

The interface is very cool and the debugging is fantastic. I am a biton the fuzzy side with any sort of WebAdministrator tasks -- It's beena while since I worked w/ ColdFusion/SQL Server so...

My plan is not to use roles, just simple login based on a User table.

string strConnection = "server=xxx;database=xxx;uid=xxx;pwd=xxxx;";
SqlConnection Connection = new SqlConnection(strConnection);
String strSQL = "Select * From user_admin";
SqlCommand command = new SqlCommand(strSQL, Connection);
SqlDataReader Dr;
Connection.Open();
Dr = command.ExecuteReader();
while (Dr.Read()) {

the while loop is where it stops saying "nvalid attempt to Read when reader is closed."
-- where i'm assuming it's not connecting to the DB and therefore has nothing to Read.

The reason I ask this to the forum is because, at one point, I haddifferent connection commands which caused an error - when I rightclicked on that error I saw a "Repair with ...?..." and I clickedok. I don't know what I did...l Anyway - if you want to look and let meknow if there's some thingreally easy you can tell me to fix, thatwould be great. ***don't spend any time on it though - I'll just dig inthe morning and find it... digging is good for learning...!

: ) But I do have a questions that I would be so so thankful if you gave meyour input on. I have setup the SQL tables and for some reason, cannotfind consistant advice on the best way to set up the unique ID. I wantit to be an autoincrement on insert kind of thing.

What I have finally settled on is the ID field being field type"int" with is identity=true, identity seed=1, identity increment =1.

The above seems to work perfect when I add a record in EnterpriseManager but since I cannot do an insert via the web, I can't test that.The big stress I'm having with it though is no matter what I try -- Icannot import any data into the tables... I have tried everywhich way configuration ofaccess,csv,tab delimeted....

I have 5 tables that need to be populated and the client gave me everything in XLS.

Oh! I have one more question...how long do I get to keep my copy ofVisual Web Developer ?

Ok.. .that's it for tonight.

You guys are great! !!!


Try this and see what happens:

string connectionString = "server=xxx;database=xxx;uid=xxx;pwd=xxxx;";
string sqlStatement = "Select * From user_admin";

SqlConnection dbConnection = null;
SqlCommand dbCommand = null;
SqlDataReader dbDataReader = null;

try
{
// Instantiate the Connection object...
dbConnection = new SqlConnection();
dbConnection.ConnectionString = connectionString;
// dbConnection = new SqlConnection(connectionString);
dbConnection.Open();

// Instantiate the Command object...
dbCommand = new SqlCommand();
dbCommand.Connection = dbConnection;
dbCommand.CommandText = sqlStatement;
dbCommand.CommandType = CommandType.Text;
// dbCommand = new SqlCommand(sqlStatement, dbConnection);

// Instantiate the DataReader...
dbDataReader = dbCommand.ExecuteReader();

// Write out the column names...
for (int i=0; i<dbDataReader.FieldCount; i++)
{
this.Response.Write("Column #" + i.ToString() + ": " + dbDataReader.GetName(i) + "<br>");
}

// Write out the column values...
while ( dbDataReader.Read() )
{
// dbDataReader.FieldCount is the number of columns/fields read.
// dbDataReader.GetName(i) is the column/field name.
// dbDataReader[i] is the column/field value.
// or dbDataReader["field-name"]

// Add the column values...
for (int i=0; i<dbDataReader.FieldCount; i++)
{
object currentObject = dbDataReader[i];
string currentValue = string.Empty;

if ( currentObject != System.DBNull.Value )
currentValue = currentObject.ToString();

this.Response.Write("Column #" + i.ToString() + ": " + currentValue + " ");
}

this.Response.Write("<br>");
}
}
catch(Exception ex){
this.Response.Write("Error: <br>" + ex.Message + "<br>" + ex.StackTrace + "<br>");
}
finally
{
// Close the DataReader...
if ( dbDataReader != null )
dbDataReader.Close();

// Kill the Command object...
if ( dbCommand != null )
dbCommand.Dispose();

// Close the Connection object...
if ( (dbConnection != null) && (dbConnection.State == ConnectionState.Open) )
dbConnection.Close();
}

NC...


I found this code that I used one time to populate a database from XML files, if it will help you:

string fileName = "xxxx.xml";

try
{
string filePath = System.Web.HttpContext.Current.Request.ApplicationPath + "\\" + fileName;
filePath = System.Web.HttpContext.Current.Server.MapPath(filePath);

DataSet dataSet = new DataSet();

// Reads the XML file into the DataSet...
dataSet.ReadXml(filePath);

DataTable dataTable = dataSet.Tables[0];

string sqlStatement = "INSERT INTO table-name-here ";

string columnStatement = string.Empty;
for (int i=0; i<dataTable.Columns.Count; i++)
{
if ( columnStatement.Length > 0 )
columnStatement += ",";
else
columnStatement += "(";

columnStatement += dataTable.Columns[i].ColumnName;
}
columnStatement += ") ";
sqlStatement += columnStatement;

string valuesStatement = string.Empty;
for (int i=0; i<dataTable.Rows.Count; i++)
{
System.Data.DataRow dataRow = dataTable.Rows[i];


// Loop through the columns for each row and grab the values...
for (int j=0; j<dataRow.Table.Columns.Count; j++)
{
if ( valuesStatement.Length > 0 )
valuesStatement += ",";
else
valuesStatement += "(";

valuesStatement += "'" + dataRow[j].ToString().Trim();
}
valuesStatement += ")";

string dmlStatement = sqlStatement + valuesStatement;
// this.Response.Write(dmlStatement + "<br>");

this.ExecuteDMLStatement(dmlStatement);
}

}
catch(Exception ex)
{
this.Response.Write("Error: <br>" + ex.Message + "<br>" + ex.StackTrace + "<br>");
}

public int ExecuteDMLStatement(string dmlStatement)
{
string connectionString = "server=xxx;database=xxx;uid=xxx;pwd=xxxx;";

SqlConnection dbConnection = null;
SqlCommand dbCommand = null;

int returnValue = 0;

try
{
// Instantiate the Connection object...
dbConnection = new SqlConnection();
dbConnection.ConnectionString = connectionString;
// dbConnection = new SqlConnection(connectionString);
dbConnection.Open();

// Instantiate the Command object...
dbCommand = new SqlCommand();
dbCommand.Connection = dbConnection;
dbCommand.CommandText = dmlStatement;
dbCommand.CommandType = CommandType.Text;
// dbCommand = new SqlCommand(dmlStatement, dbConnection);

// Execute the Command object...
returnValue = dbCommand.ExecuteNonQuery();
}
catch
{
throw;
}
finally
{
if ( dbCommand != null )
dbCommand.Dispose();

if ( dbConnection != null )
dbConnection.Close();
}

return returnValue;
}

NC...


this was incredibly helpful! i got it running just fine and now all i have to do is mix in my working validation code.

I did get an error on the "("Error: <br>" + ex.Message + "<br>" + ex.StackTrace + "<br>");" -- it didn't know what "ex" was. I also couldn't find where "Message" was setup. I took it out and all is well. I'll do some reading on try,catch & finally...

thank you SO much!

i'll be trying the xml trick next!!


Sorry, that's because thecatch line should becatch(Exception ex). I fixed the post for future readers.

NC...


ok thanks...

i got my login working and then i did a copy site and ftp'd all the files onto the web and now i'm getting that Server Error error again... i tried creating a new website - directly FTP'ing onto the server...same error.The new site zer0 code - just the blank outline that 'new site' creates and still error. i made an index.html that i can go to ok...??

i swear i'm almost independant!

Error:

Server Error in '/' Application.
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".

my web.cofig looks like this:

<?xmlversion="1.0"?>

<configuration>

<appSettings/>

<connectionStrings/>

<system.web>

<roleManagerenabled="true" />

<compilationdebug="true"/>

<authenticationmode="Forms" />

<customErrorsmode="Off"defaultRedirect="GenericErrorPage.htm">

<errorstatusCode="403"redirect="NoAccess.htm" />

<errorstatusCode="404"redirect="FileNotFound.htm" />

</customErrors>

</system.web>

</configuration>


Did you set Debug="True" in the page directive?

suddenly cant use breakpoints

this drives me cuckoo....

i have an application i've been working on for months and for some reason today the development environment completely ignores breakpoints. the app just runs and never breaks on any of my breakpoints. this happened to me once before but i can't recall what caused it.

anyone know what causes that?

Chances are you already checked these, but go to Build | Configuration Manager to make sure you're using the Debug mode. Also, run your app with F5, not Ctrl-F5. Finally, if you're using ASP.NET 2.0, be sure the following is in your Web.config file:

<compilationdebug="true"/>


i am in debug mode...

i use f5

i am not using 2.0 (use 1.1)

and yet it always goes right past any break points


close VS and restart it...

Also, is this ALL breakpoints? If you set one in the first page in the page_load does it stop?


i closed it down...restarted it...

put a break on page_load

it ignores it


Check in the Project Properties, make sure that "Enable ASP.Net Debugging" is checked...
it is checked

Check the web.config then...

<compilation.........debug="true"></compilation>


yes...web.config has debug=true

i just rebooted my machine but it still ignores breakpoints


Here's something you can try (copied from some other site):

Select "Debug" from the "Solution configuration" combobox which is embedded
into VS.NET's toolbar. If the project/solution is compiled using the
"Release" configuration, no debug symbols (PDB files) are created. Use this
configuration when compiling the release version of a product. If this
doesn't fix your problem, delete its "obj" and "bin" directories and
recompile.

Suddenly can't load assembly

I am using VS2005, and yesterday I copied a web site from my
development machine to
a Windows 2003 server, and the web site worked fine.
Today I made a few changes on my machine, and tried to repeat the
process,
but I get an error message:
Could not load file or assembly 'BaseRS' or one of its dependencies.
Access is denied
BaseRS.dll is in the bin folder, as it was previously.
Any ideas about what causes this message?What were the "few changes" you made ?
Anything to do with file permissions or the ASP.NET account ?
Did you enable impersonation and now a different account needs permissions ?
Juan T. Llibre
ASP.NET.FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Espaol : http://asp.net.do/foros/
======================================
<jhcorey@.yahoo.com> wrote in message news:1133453674.384226.289410@.z14g2000cwz.googlegroups
.com...
>I am using VS2005, and yesterday I copied a web site from my
> development machine to
> a Windows 2003 server, and the web site worked fine.
> Today I made a few changes on my machine, and tried to repeat the
> process,
> but I get an error message:
> Could not load file or assembly 'BaseRS' or one of its dependencies.
> Access is denied
> BaseRS.dll is in the bin folder, as it was previously.
> Any ideas about what causes this message?
>
Did you try IISReset before doing the deployment.
If not, you may like to do that. Also, clear all your Temporary Asp.net
files from the folder C:\WINNT\Microsoft.NET\Framework\v2.0.50727\Temporary
ASP.NET Files
before you deploy the application.
If that doesn't help you can try Filemon utility from www.sysinternals.com
and serch for access denied after you reproduce the error and save the log
file from the Filemon utility.
HTH
--
Cheers,
Rahul Soni
-->The secret to creativity is knowing how to hide your sources<--
"jhcorey@.yahoo.com" wrote:

> I am using VS2005, and yesterday I copied a web site from my
> development machine to
> a Windows 2003 server, and the web site worked fine.
> Today I made a few changes on my machine, and tried to repeat the
> process,
> but I get an error message:
> Could not load file or assembly 'BaseRS' or one of its dependencies.
> Access is denied
> BaseRS.dll is in the bin folder, as it was previously.
> Any ideas about what causes this message?
>
The app does use impersonation, and that may have been a change in the
web.config.
(Although it uses anonymous access, and yes there was a reason for this
that made sense at one point).
I can experiment without impersonation and see if that makes a
difference. What would I do if it does?
I'm not familiar with any new deployment procedures, so I figure I
better take a look in help.
But I assumed that copying the folders would work for deployment, as it
did in ASP.NET 1.
Anyway, I'll try Rahul's suggestions as well, thanks.
re:
> I can experiment without impersonation and see if that
> makes a difference. What would I do if it does?
Run this aspx page :
identity.aspx :
--
<%@. Page Language="VB" %>
<script runat="server">
Sub Page_Load(obj as object, e as eventargs)
Dim user as string = Environment.Username
lblUser.Text = user
End Sub
</script>
<html>
<body>
<asp:Label id="lblUser" runat="server"/></asp:Label>
</body>
</html>
--
That will tell you which account needs permission to the directory
where the BaseRS assembly is located ( the /bin dir, right ? ).
Juan T. Llibre
ASP.NET.FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Espaol : http://asp.net.do/foros/
======================================
<jhcorey@.yahoo.com> wrote in message news:1133455339.559879.253270@.g44g2000cwa.googlegroups
.com...
> The app does use impersonation, and that may have been a change in the
> web.config.
> (Although it uses anonymous access, and yes there was a reason for this
> that made sense at one point).
> I can experiment without impersonation and see if that makes a
> difference. What would I do if it does?
> I'm not familiar with any new deployment procedures, so I figure I
> better take a look in help.
> But I assumed that copying the folders would work for deployment, as it
> did in ASP.NET 1.
> Anyway, I'll try Rahul's suggestions as well, thanks.
>
Juan,
Impersonation was indeed the issue. The impersonation user id is from
a different domain.
For some reason this did not cause a problem on my development machine.
I'm not sure if I should address this within the folder system or
within IIS6.
I tried changing the security on the folder (it already had 'Everyone'
with full control)
to give explicit access to this userid, but it didn't help.
Thanks,
Jim
Finally got this working (I think)
After quite a bit more playing around with security for impersonated
user,
I googled some more and saw that I had to grant permissions (full
control) on
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files
and so I'm running...
Jim