|
wht the .. some people say "plz post more details then some say post a section" wht u all programmers r thinking actually.. anyway wht useless ans u all give.. i have found out the ans myself !! all u supposingly smart ass jus didnt provide any help .. im new in c# yet i solve myself..haha!!
|
|
|
|
|
Congratulations. you just made my list of posters to ignore in the future. Glad you're able to solve your own problems, because you are certainly going to get to in the future...
|
|
|
|
|
hey
i am developing a web application using asp.net, but coding in C#.
i need to insert into my database (sql server 2000/access). how shud i do it.
i have two textboxes.. watever the user enters in it, it shud be added in a particular table.
Kunal Piyush
|
|
|
|
|
shud ?
The fact that your ASP.NET codebehind runs on the server means the code is no different to accessing a database using WinForms. Any help you can find on the web for database access will work just fine.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
i coded a bit.. but now sql database i showing an error if i keep the field "Username" as a primary key.
firstly the data is entered in a very ad-hoc fashion.. there is a row empty at the top...data entered in between two rows which are already filled with data..
and if i delete some data,then i get the error as
"Another user has modified the contents of the table,the database row ur modifying no longer exists in the database....... violation of PRIMARY KEY constraint...."
THE CODE:-
try
{
SqlConnection conn = new SqlConnection("server=(local);" +
"database=path;" +
"connection timeout=3;" +
"Trusted_Connection=yes;" +
"Integrated Security=true;" +
"user id=sa;" +
"password=");
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = "Insert into login(Username,Password) values('"+uname.Text+"','"+pass.Text+"')" ;
SqlDataReader dread = cmd.ExecuteReader();
if (dread.Read())
{
failed.Text = "Could not add the user";
}
else
{
Response.Redirect("success.aspx");
}
conn.Close();
}
catch(Exception kp)
{
failed.Text=kp.Message;
}
}
Kunal Piyush
|
|
|
|
|
the question is simply this boys n girls, ladies n gents,
how do I iterate thru all the elements of a Datagrid in a windows form (.net 1.1). thats when I take input from user. how do i know the number of rows entered in it.
thanks
I'd appreciate if u tel me that in c# but anyways tahts not compulsory
thanks in advance
|
|
|
|
|
Doesn't the DataGrid have a Rows property, which has a Count property ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
OK got ur point, stupid question I know
|
|
|
|
|
wait a second here I think this property is not therein Windows Forms, I might still be wrong though, I'm sorry for taht in advance but I got the other way around to this like
DataTable dt = (DataTable) dg.DataSource;
dt.Rows.Count
casting the DataGrids Datasource into a table and then using its count
but I'm not so sure if it will work when the using is giving data for input
|
|
|
|
|
Just one more question here, God I'm a real new commer here,
ah how do u empty a datagrid.
I want the datagrid showing an existing set of records to get empty when I click a button for adding a new record. Its actually a master detail form. The master table is linked with a set of textboxes and comboboxes and The details are in the datagrid. I hope the scenario is clear now and I repeat I'm using .net 1.1 and working in Windows Forms. So I need the info abt System.windows.Forms not the other one
thanks in advance...
Rocky
|
|
|
|
|
clear the datascource
grdDetails.DataSource = Nothing
|
|
|
|
|
Thanks I got this idea a little while b4 I read this but I really appreciate it.
|
|
|
|
|
Well right now I'm working on that same form to save the data. I've made the sqlDataadapters for the master and the detail tables which offcourse have the update,select insert, del commands.
But I'm a bit confused in whether if I should add() the new row of data in the master table b4 taking the input from the datagrid or not.
Can anyone plz give me a few guidlines or a tip or 2 abt this. I'm doin this for the first time actually. If u can give any useful Urls, that wuold be nice too.
thanks
|
|
|
|
|
Can anybuddy provide me some good helping material (reading, code etc) for making master detail forms (C# preferably)
|
|
|
|
|
You can get so many examples on net for that if you will use google :
here is the one:
http://msdn2.microsoft.com/en-us/library/c12c1kx4.aspx
Best Regards,
Apurva Kaushal
|
|
|
|
|
Thanks a lot, I appreciate it. yesterday I worked on the form and its del command is working allright now. I havent worked on updates as yet.
I'm having a little problem in inserting data in the detail table. Its shown in a datagrid and I dont know, the records get inserted automatically thru the grid. Its strange for me. How can we stop this behaviour ir use it more inteligently for our purpose?
Thanks a lot...
|
|
|
|
|
private void MakeReadOnly()
{
dataGridView1.AllowUserToAddRows = false;
dataGridView1.AllowUserToDeleteRows = false;
dataGridView1.ReadOnly = true;
}
I think I got the clue here. is that it?
|
|
|
|
|
I had a hard time installing MSDE 2000 onto my system but I eventually did. However, when I check my add remove programs all I see in there is Microsoft SQL CE 2.0 Server Tool but no SQL server. Futhermore everytime I re-start I get a message that states:"The system can not find the file specified". First I am not sure if MSDE was fully installed, since I was getting an error message before. Second: I am not sure how to assign service to application since its computer name appears in there but yet it can nto find service.
1. So my question is how do I assign service to SQL server?
2. How do I know that it is MSDE that is installed?
3. I am getting an error when attempting to start MSSQL Server AD Helper?
Thanks and any information which can help will be greatly appreciated.
Greg
Coding makes the world go round!!!
|
|
|
|
|
1. You shouldn't have to do anything, install should take care of this.
2. from your description, it's not. You should be able to open the services admin tool , and see mssqlserver service. you should be able to start and stop it. There shouldbe a small "server" icon in the system tray (XP). A right click there should get "open Sql Server Manager" as a menu item. from the manager you should be able to start/stop the server, Sql Server agent and DTC.
3. if the server itself is not running, the AD helper can't start.
I would uninstall and try again (what problems did you have installing it - what OS are you installing to?)
|
|
|
|
|
I restarted and before I knew it was up and running fine with service and everything. Thanks
PS: I was using XP.
Greg
Coding makes the world go round!!!
|
|
|
|
|
select SUBSTRING(dmv2_data_text, 40, DATALENGTH(DMV2_DATA_TEXT))
from dmv2 WHERE DMV2_RCD_TYPE = 'R'
When I run this query sometimes there's a carriage return sometimes there isn't. Is there a way to inspect the first char and see if there is a CR and if so shift the whole string over one more space to remove it?
Thanks
Tom Wright
tawright915@gmail.com
|
|
|
|
|
SELECT CASE WHEN SUBSTRING(dmv2_data_text, 40, 1) = CHAR(13)
THEN SUBSTRING(dmv2_data_text, 42, DATALENGTH(DMV2_DATA_TEXT))
ELSE SUBSTRING(dmv2_data_text, 40, DATALENGTH(DMV2_DATA_TEXT))
END
FROM dmv2 WHERE DMV2_RCD_TYPE = 'R'
If it is a carraige return, then add two (carriage return + line feed).
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
nope still didn't do it. I may have to just live with is and remove it in my code instead of thru SQL.
Thanks
Tom Wright
tawright915@gmail.com
|
|
|
|
|
TableName:MyTestTable
ColumnName:TestCol
Two Records:
1='
This<br />
is a test '
2='
This is also<br />
a test '
SELECT '--' + CASE WHEN SUBSTRING(TestCol, 5, 1) = CHAR(13)
THEN SUBSTRING(TestCol, 7, 256)
ELSE SUBSTRING(TestCol, 5, 256)
END
FROM MyTestTable
Result:
--is a test<br />
-- is also<br />
a test<br />
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
Okay, I still could not get it to work. So I copied the data from Query Analyzer and pasted into a hex editor and saw that the char before my string is a hex 20...a space. So I tried the query you suggested only make the CHAR(13) to a CHAR(20) and CHAR(32)...still did not work.
Could there be something else there and the system sees and is not reading it right?
Thanks for the help
Tom Wright
tawright915@gmail.com
|
|
|
|