|
here is ur solution
http://support.microsoft.com/default.aspx?scid=kb;en-us;139444
|
|
|
|
|
Thanks!
Didnt think it would be so complicated!!!
|
|
|
|
|
Hello, i'm novice with Visual C# and SQL Server, so can someone help me please ... i want search for a record in the database, and if it is found then i move the CurrencyManager position to its position but i got this error:
ConstraintException was unhandled:
Column 'cd_id' is constrained to be unique. Value '9463216602' is already present.
in my database this field [cd_id] in both tables aren't the primary key, are just simple fields ... what's i'm doing wrong, can someone help me please, i'm using this code:
the general variables:
<br />
SqlConnection myConnection;<br />
SqlDataAdapter daCD, daTemas;<br />
DataSet myDataSet = new DataSet("MusicaTeca");<br />
DataViewManager myDVM;<br />
CurrencyManager cm;<br />
in the form_load:
<br />
private void frmProduto_Load(object sender, EventArgs e)<br />
{<br />
myConnection = new SqlConnection(<br />
"Server=(local)\\SQLEXPRESS;DataBase=musicateca;" +<br />
"integrated Security=SSPI");<br />
<br />
daCD = new SqlDataAdapter("SELECT * FROM tbl_cds", myConnection);<br />
daCD.TableMappings.Add("Table", "tbl_scds");<br />
daCD.Fill(myDataSet, "tbl_cds");<br />
<br />
daTemas = new SqlDataAdapter("SELECT * FROM tbl_temas", myConnection);<br />
daTemas.TableMappings.Add("Table", "tbl_temas");<br />
daTemas.Fill(myDataSet, "tbl_temas");<br />
<br />
myDVM = myDataSet.DefaultViewManager;<br />
<br />
DataRelation relCD_Tema;<br />
DataColumn parentCol, childCol;<br />
parentCol = myDataSet.Tables["tbl_cds"].Columns["cd_id"];<br />
childCol = myDataSet.Tables["tbl_temas"].Columns["cd_id"];<br />
relCD_Tema = new DataRelation("RelCD_Temas", parentCol, childCol);<br />
myDataSet.Relations.Add(relCD_Tema);<br />
<br />
txtAlbum.DataBindings.Add("Text", myDVM, "tbl_cds.album");<br />
txtAno.DataBindings.Add("Text", myDVM, "tbl_cds.ano");<br />
txtArtista.DataBindings.Add("Text", myDVM, "tbl_cds.artista");<br />
txtEditora.DataBindings.Add("Text", myDVM, "tbl_cds.editora");<br />
txtGenero.DataBindings.Add("Text", myDVM, "tbl_cds.genero");<br />
txtID.DataBindings.Add("Text", myDVM, "tbl_cds.cd_id");<br />
<br />
dbGrid.DataSource = myDVM;<br />
dbGrid.DataMember = "tbl_cds.RelCD_Temas";<br />
dbGrid.Columns["reg_id"].Visible = false;<br />
dbGrid.Columns["cd_id"].Visible = false;<br />
<br />
cm = (CurrencyManager)this.BindingContext[myDVM, "tbl_cds"];<br />
}<br />
and the search button_click:
<br />
private void btnLocalizar_Click(object sender, EventArgs e)<br />
{<br />
int intRow;<br />
<br />
myDVM.DataViewSettings["tbl_cds"].Sort = "cd_id";<br />
intRow = myDataSet.Tables["tbl_cds"].DefaultView.Find(txtID.Text);<br />
<br />
if (intRow > 0)<br />
{<br />
cm.Position = intRow;
cm.Refresh();<br />
}<br />
else<br />
{<br />
MessageBox.Show("Registo não localizado!");<br />
}<br />
}<br />
can someone help me please ... and forgive me my bad english.
Thanks
UltraMAX
|
|
|
|
|
A field need not be a primary key to have a unique constraint. Sounds like cd_id has a unique constraint or index defined for it. Check the db definitions.
Absolute faith corrupts as absolutely as absolute power
Eric Hoffer
All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke
|
|
|
|
|
i think you have set up the relation between the two tables in the dataset memory, hence your parent table which contains is taken as the primary key.
Please check out this.
|
|
|
|
|
Thank you guys for helping me ... jesus ... like i said i'm novice in .NET, i've used VB6 before, but it's completly different, and i've used with Ms ACCESS ... please, can you guys give me just a little example using the code that i'm using or just the code that is missing to resolve that, please!!!
|
|
|
|
|
I am using sql-server 2000 database. i am trying out document managment . can anybody tell me How do i store an MS-OFFICE document into a database table. i have created a table with the the column name as "document" datatype as varbinary.
Any help would be welcome
anil g
-- modified at 11:41 Wednesday 14th December, 2005
|
|
|
|
|
varbinary is unlikely to be large enough (unless you are using SQL Server 2005) as its maximum size is just under 8K. You need to create the column as an image (the 2Gb limit should be sufficient for office files.)
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
thanks for the tip. Also can you guide me with the sql statements for storing
it as an image ?
|
|
|
|
|
Ok im sure this is simple but im new to SQL and dont want to mess things up so your assistance please.
Im using a MS SQL server, which holds client contact details. However in the email field some contacts do not contain properly formatted email adresses.
eg www.somewhere.com rather than someone@somwehere.com
So what sql statement would i run to delete these fields?
Is it as simple as:
Delete * From table WHERE email NOT LIKE %@%
(im looking for records without a '@' symbol)
Thanks!
|
|
|
|
|
try this
delete from table where email not like %@%
--this query deletes all rows in which doesnt exists character @
|
|
|
|
|
Yeah,
Thought so!
Thanks for confirming.
|
|
|
|
|
u are welcome
|
|
|
|
|
OK all. I installed VS2005 Pro with SQL Express. No problems. I went to the Microsoft Learning Center[^] web site for the Visual Web developer and started watching the videos. However, when I try to follow the Lesson 8 video, I can't get the Advanced SQL Connection options to show themselves (they are all greyed out). So when I try to add a control that allows data editing to an ASPX page, I can't turn on the editing feature. Is this something in SQL Express I have to configure?
Regards,
Brigg Thorp
Senior Software Engineer
Timex Corporation
|
|
|
|
|
Help!
I installed VWD 2005 with SQLEXPRESS 2005 and the management tools. Now when I try to create a new DB in VWD I get a error "Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance."
Please help.
Illegal Operation
Making Computer Software Talk
|
|
|
|
|
|
update command for interchanging to field values
ex.
f_name L_name
--------------------------
a b
c d
by mistake f_name went to l_name and vise varsa
|
|
|
|
|
Hi,
Why don't u try with cursors......
e.g
DECLARE authors CURSOR FOR
SELECT au_id, f_name, l_name
FROM authors
OPEN authors
FETCH NEXT FROM authors
INTO @au_id, @au_fname, @au_lname
WHILE @@FETCH_STATUS = 0
BEGIN
Update author_master
SET f_name = @au_lname,
l_name = @au_fname
WHERE au_id = @au_id
FETCH NEXT FROM authors_cursor
INTO @au_id, @au_fname, @au_lname
END
CLOSE authors
DEALLOCATE authors
GO
I hope this will help u....
Regards,
Ritesh
|
|
|
|
|
|
Simply run the update command. Below is a sample.
CREATE TABLE dbo.ctm
(
id numeric(18,0) IDENTITY,
col1 varchar(20) NULL,
col2 varchar(20) NULL
)
go
INSERT INTO dbo.ctm ( col1, col2 ) VALUES ( 'aa', 'bb' )
INSERT INTO dbo.ctm ( col1, col2 ) VALUES ( 'cc', 'dd' )
SELECT T.id, T.col1, T.col2 FROM dbo.ctm T
update ctm
set col1 = col2, col2 = col1
SELECT T.id, T.col1, T.col2 FROM dbo.ctm T
|
|
|
|
|
Hi experts,
I have the following problem when saving data from an XML-file to a database using the OleDbDataAdapter:
I'm using a typed dataset, derived from the xml-schema.
I load the xml-file into the dataset and try to save the data to the database. (the dataAdapter has all the commands (select, insert, update, delete) properly configured.
When it's all new data, there's no problem, all data is saved correctly.
But it's also possible that the xml-file contains data that is already in the database (primary key already exists), so this data needs to be updated (instead of re-inserted)(this is what a dataAdapter takes care of, right ?)
I tried 2 approaches:
1) Only loading the xml-data into the dataset:
When i use the update-method of my dataAdapter and there is data that is already in the database (primary key already exists) i get an oleDbException.
2) First load the database-data in the dataset, and then load the xml-file in the dataset:
I get a ConstraintException while loading the xml-data because primary key already exists in the datatable of the dataset.
How can I fix this problem so that I get 1 table with updated old data and inserted new data ?
Any help is much appreciated... Thanks in advance...
John
|
|
|
|
|
I need to Get data from my Sql Server 2000 database from my web site host to my local dataserver. I need to do this in a way that the data is secure. I can use Enterprise manager to import data but this is not secure or is it?
Thanks
|
|
|
|
|
You could use ASP.NET and encryption. See this.[^]
Farhan Noor Qureshi
if (this == this) thow this;
|
|
|
|
|
Here is the situation:
The user logs onto the database and calls a sql server extended stored procedure. I wrote the extended stored procedure in C/C++. How do I call another stored procedure from the C/C++ code? I want to do this without connecting to the database again (the extended stored procedure is already running within the sql server process). What is the API I should use (if there is any)?
My articles and software tools
|
|
|
|
|