|
simply id is a long numner so it donesn't need about ' '. so:
ID = id; is correct
|
|
|
|
|
Again, I'll recommend parametizes queries for many reasons. See my reply to your thread above.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Try out these one i think it will work for u
query = "DELETE * FROM myTable WHERE ID = " + id ;
if not contact me (ravikim2001@yahoo.co.in)
ok bye.
Happy coding
|
|
|
|
|
|
how can i insert the picture to the sqldatabase ?what datatype cani use ?
how can i load the picture to the database?can you give me the code with c#.net to insert picture from the webform.asp to the sqldatabase?
|
|
|
|
|
|
My boss would like make peer evaluations done on an electronic basis, he needs each employee to fill out a form like:
-your name "tom"- -person being evaluated's name "bob"-
q1 - response
q2 - response
ect...
The admin should then be able to do a search for "bob" and then a summary report will be made with the questsions asked and every ones responses about "bob"
q1 - "bill's response"
- "tom's response"
but none of the submitted reports should be accesible to other users besides the admin. So how can one submit something then not have access to it? i know its a simple problem but.... gah..
|
|
|
|
|
I would have thought this would be an application level thing rather than a database level thing.
Each user would be allowed to create an edit their own rows via the application. The application would only permit them to see data that they entered. Admin users (in this instance, however, it sounds more like managerial users) would be able to see everything.
Each row would contain the username of the person that created it. The application that is interacting with the database would contain in the WHERE clause the necessary filter, e.g. WHERE username = @loggedOnUser
Ian McCloy wrote:
So how can one submit something then not have access to it? i know its a simple problem but.... gah..
This sounds crazy. But you could:
GRANT INSERT ON [table_name] TO [user]
REVOKE SELECT ON [table_name] TO [user]
or if you are accessing only through stored procedures, then you only provide access to stored procedures that permit the data to be inserted.
Personally, I would say it is always better for a user to be able to review and edit their own work. For example, I don't like forums where I cannot edit my posts (I often modify a post to correct spelling errors that I didn't pick up on the first time)
My: Blog | Photos | Next SQL Presentation
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
Can I use the Same Table structures, triggers, sprocs and UDF's that was developed in SQL 2000 in YUKON.
Is Migration Simple?. Or Do i have to change some code.
If yes how much.
Thanks in Advance
Ashok
|
|
|
|
|
I can't imagine why you'd have to change anything particularly
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
do u mean Just taking the databases from 2000 to yukon will work?
|
|
|
|
|
I mean that I would expect that to be the case, yes. I'm not saying I've tried it, but they're not going to change T-SQL to make old stuff stop working, surely ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
How to insert text in MEMO field?
(I'm using Access DB and VS2003)
|
|
|
|
|
Hello,
I am currently porting software for my University from MSSql to MySql. I am having some problems and would really appreciate any help you could give.
I am unable to change the core design of the database tables because another student is working on software to process the resulting data, and he is hard coding everything. I have expressed how this is a bad design idea, but to no avail. So I am stuck with the current design.
In this design, the tables use a varchar(8000) as a primary key for relating the tables. This is automagically cast into a TEXT field by MySql, and it of course throws the error that a TEXT field as a primary key must have an index. I went ahead and gave indexes to all those text fields and everything on that part works great.
However, later in the database creation there are some constraint commands put on these tables that use those TEXT fields as the foreign key, and when it sees that this foreign key is a TEXT field it throws an error that a lenght must be specified.
I have no idea (after reading the manual again) how to specify a length in the constraint command. If you know how please let me know, I can post the code if that would help.
Thanks
Tim Reynolds
|
|
|
|
|
razialx wrote:
from MSSql to MySql.
Why do you need to do this ? If it's a cost issue, have you looked into MSDE ?
razialx wrote:
In this design, the tables use a varchar(8000) as a primary key for relating the tables.
Your co student is an idiot. I can't think of a worse design, no matter how hard I try. I'd urge you to distance yourself from this cowpat of a project ASAP. A primary key is an index, it needs to be easy to search. A varchar(8000) is about as far from that as you can get.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote:
Your co student is an idiot. I can't think of a worse design, no matter how hard I try.
I bet he gets lots of warning messages too saying that the design makes it possible to create a valid row greater that 8000 bytes which cannot be processed. Since I've never gone nuts like this I've never seen the actual message so I'm not sure what it says, but I'm told it exists.
My: Blog | Photos | Next SQL Presentation
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
Christian Graus wrote:
I can't think of a worse design, no matter how hard I try. I'd urge you to distance yourself from this cowpat of a project ASAP
Ah! I so much agree!
Christian Graus wrote:
A primary key is an index, it needs to be easy to search
I suspect the original designer (designer?) was using some kind of guid as unique key because he/she did not wish to or know how to let the database generate the key.
Sorry I can't give you any practical advise to solve your current problem.
|
|
|
|
|
Guys, I know its terrible. I don't have a choice here.
I will explain a little about the project and my role in it...
This other student developed an online questionnaire program for use in teacher evaluations. I did not initiate this project or have any part in its design... I wish I had at this point. This last semester I was in a Windows Programming course, and having developed quite a bit of software in .NET I was allowed to work on a variety of projects in place of creating console based Hello, World! demos. The last project I was placed on was this. The project was already considered 'done' when I started working on it, they just wanted me to convert it from a retail database into an open database (the only open source support I have seen at this university...). When I inquired about this terrible design, I was told it was this way so that question numbers could be represented as strings and be kept unique. By this I mean the data could be described as such:
"Q1" "Did your teacher give you a better understanding of the subject material?" "bool"
"Q1.1" "Yes"
"Q1.2" "No"
Right, well thats all good until you consider just using an auto-incrementing integer as the primary key to reference things and attributing the question names as being unique.
I must also restate that I can NOT change this design, no matter how difficult it is to accept... /sigh.
I can still only plead with you folks and your experience on this, because I must get it working.
If we were to only consider the varchars as being 10 in lenght (because if someone were to show me a question number 8k long, I would quit programming!). Do you know how I could use this as a foreign key in a constraint statement?
If you know for a fact that it will not be possible, tell me so I can try another avenue.
And just to pull the sympathy card on my plight, I have to piece together all SQL statements from 50+ lines of :
strCmd += "...";
strCmd += "...";
...
strCmd += "...";
and so on and so on. Because putting the SQL statements into an editable format would be out of the question.
Thank you for those who have replied thus far, I hope you can help me come to a solution on my problem.
Tim
|
|
|
|
|
Hi to you all,
i'm still hardly writing my first web app and i'm actually trying to build some update/delete/insert query, you cas see the function i wrote.
in the second part of my query "Industry" i have to write directly the values in the command string because if a use "?" and parameters i get an exception of "non corrispondence" between parameters.
will anybody help me?
thanks in advance!
Fuel2Run
here is the query function:
Shared Function AddCompany(ByVal actC As CoreLayer.Company) As Boolean
Dim connStr As String = System.Configuration.ConfigurationSettings.AppSettings("connectionString")
Dim myConnection As New OleDbConnection(connStr)
myConnection.Open()
Dim myCommand As OleDbCommand = myConnection.CreateCommand()
Dim myTrans As OleDbTransaction
myTrans = myConnection.BeginTransaction(IsolationLevel.ReadCommitted)
myCommand.Connection = myConnection
myCommand.Transaction = myTrans
Try
' company
myCommand.CommandText = "INSERT INTO P5_companies (company_name, Adress, Town, Country, Notes ) VALUES (?,?,?,?,?)"
'cmd.Parameters.Add("actUser", OleDbType.VarWChar, 15)
'cmd.Parameters(0).Value = TheUser
myCommand.Parameters.Add("company_name", actC.Name)
myCommand.Parameters.Add("Adress", actC.Adress)
myCommand.Parameters.Add("Town", actC.Town)
myCommand.Parameters.Add("Country", actC.Country)
myCommand.Parameters.Add("Notes", actC.Notes)
myCommand.ExecuteNonQuery()
' ID...
myCommand.CommandText = "SELECT @@IDENTITY"
Dim actID As Int32 = CType(myCommand.ExecuteScalar, Int32)
If Not actC.Activities Is Nothing Then
If actC.Activities.Count > 0 Then
' activitites
Dim actA As CoreLayer.Industry
For Each actA In actC.Activities
myCommand.CommandText = "INSERT INTO P5_activities (companyID, industries) VALUES (" & actID & "," & actA.ID & ")"
'myCommand.Parameters.Add("companyID", OleDbType.Integer).Value = actID
'myCommand.Parameters.Add("industries", OleDbType.Integer).Value = actA.ID
myCommand.ExecuteNonQuery()
Next
End If
End If
myTrans.Commit()
Return True
Catch e As Exception
myTrans.Rollback()
Return False
Finally
myConnection.Close()
End Try
End Function
|
|
|
|
|
I hav insered a ListBox in the header of a datagrid and i can't find the event "SelectedIndexChanged" of this ListBox .
ENSI TUNISIA
|
|
|
|
|
|
ah sorry itsn't a textbox but a listbox
ENSI TUNISIA
|
|
|
|
|
Hello,
In Windows Forms, I have a datagrid that is sortable by clicking on the column headers.
Say 2nd record is already selected and I sort the datagrid.
Now this previously selected row is unselected. At this point how do I get the index to this previously selected row to have it selected again.
The issue I'm referring is that after sorting the dataset still has the same indexing order on the datagrid, meaning, a particular row's index before or after sorting remains intact eventhough after sorting it's position on the datagrid view has changed.
Thank you.
|
|
|
|
|
I'm trying to do the same thing.
If you find out a way do it let me know,
Thank you
|
|
|
|
|
Two part to this.
Part1 (Save Row ID)
Each time a user selects a row in your DataGrid you need to save the row's unique idenifier.
Part2 (Re select Row based on ID)
After sorting, locate the new location of your selected row using the saved unique row identifier.
Example Part 1
IEnumerator enu = ((DataView)DataGrid1.DataSource).GetEnumerator();
int index = 0;
while( index <= DataGrid1.SelectedIndex )
{
enu.MoveNext();
index++;
}
DataRowView rowView = enu.Current as DataRowView;
DataRow row = rowView.Row;
ViewState["item"] = (int)row["ID"];
Example Part 2
DataView sortView = dataSet1.MyTable.DefaultView;
if( ( numberDiv % 2 ) == 0 )
{
sortView.Sort = e.SortExpression + " ASC";
}
else
{
sortView.Sort = e.SortExpression + " DESC";
}
numberDiv++;
ViewState["sort"] = sortView.Sort;
DataGrid1.DataSource = sortView;
DataGrid1.DataBind();
if( ViewState["item"] != null )
{
int id = (int)ViewState["item"];
int index = -1;
IEnumerator enu = sortView.GetEnumerator();
while(enu.MoveNext())
{
index++;
DataRowView rowView = enu.Current as DataRowView;
DataRow row = rowView.Row;
int rowID = (int)row["ID"];
if(rowID == id)
{
break;
}
}
DataGrid1.SelectedIndex = index;
}
Hope this helps.
My thanks to minhpc_bk
|
|
|
|