|
|
After executing a select query the data provider returns the value in a varchar field in a .NET Unicode string, how does it determine the encoding conversion to perform? My guess is that it's determined by the collation setting on the column, but I'm not sure? For example, if the collation is SQL_Latin1_General_CP1_CI_AS, the Provider converts from code page 1252 to Unicode.
Does anyone know for sure the strategy applied here?
|
|
|
|
|
Hi
I have a table T with columns ID(int) , visible(bit);
visible cells are 1 or 0;
when i write "SELECT visible FROM T " in the query analyzer i got list of 1 and 0;
when i write "SELECT visible FROM T " in the VS in a sp and run it i got a list of 0 and -1 instead 1
WHY ?
|
|
|
|
|
|
Can someone please help me with error handling in SQL 2000? If an entry allready exist then the user must not be able to add the duplicate and he must be warned that there is a duplicate.
Illegal Operation
Making Computer Software Talk
|
|
|
|
|
|
I have configured the table with the unique constraints but now I want to catch the error generated by SQL and then display or give it a meaningfull way to handle.
In other words, when the error occurs in SQL, I need to redirect the user to another page.
Illegal Operation
Making Computer Software Talk
|
|
|
|
|
Declare @intErrorCode int<br />
select @intErrorCode = @@Error<br />
<br />
begin transaction<br />
<br />
If @intErrorCode = 0<br />
begin<br />
-- insert SQL Statement<br />
set @intErrorCode = @@Error<br />
end<br />
<br />
If @intErrorCode = 0<br />
begin<br />
-- insert another SQL Statement<br />
set @intErrorCode = @@Error<br />
end<br />
<br />
<br />
IF @intErrorCode = 0<br />
commit transaction<br />
else<br />
rollback transaction<br />
return @intErrorCode
To handel the error in your page use the
Try <br />
Cmd.ExecuteNonQuery<br />
catch ex as sqlclient.sqlexception<br />
'Put code to redirect<br />
End Try
"People who never make mistakes, never do anything."
My blog
http://toddsnotsoamazinglife.blogspot.com/
|
|
|
|
|
Hi,
In a relational database, I would to like to know the performance difference between of using a string and an integer as the primary key field for the tabl;e. Will a column field of integer be indexed faster than a string column field ?
Thanks
|
|
|
|
|
CraigBurton wrote:
Will a column field of integer be indexed faster than a string column field ?
Yes, simply because the key will be smaller. The smaller the key the faster it can be indexed and retrieved because the index will be smaller overall and it won't have to pull so much data off the disk in order to scan the index.
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
Thanks
Besides integer is smaller than string, will implicitly
the indexing of integer is faster than string, if they are of
similar length ?
How about for the retrievel after indexing, should be same ?
|
|
|
|
|
|
when i expand the enteprize manager i get the no item error .i increase any time in the option but no advantage... .! i am not the owner of the database .is this is the reason of that error.
|
|
|
|
|
Hi,
I have written a VB6 program that uses a datagrid bound to a ADO data control. I do the following:
Adodc1.ConnectionString = "DSN=" & m_objSentryDB.DSN & ";uid=" & strUserID & ";pwd=" & strPassword
Adodc1.RecordSource = strSQL
Set DataGrid1.DataSource = Adodc1
This is working fine, however, when I want to close the program, how do i CLOSE the connection opened by the ADODC control? I am using a sybase database, and they is basically one ghost connection on the server remaining after each use of the program. I looked for a 'close' method on the ADODC object, but to no avail.
Also, what is the correct way to refresh the grid after the underlying table has changed? I use adocdc1.refresh, but this seams to knock out the display properties of the grid (size, caption etc).
Any ideas?
thanks
Maitre Capelo
|
|
|
|
|
please anybody knows in c# how can I add new records in joined tables?
|
|
|
|
|
|
i was talking how to do it by code in c#.
can you help me with an example?
i have 1 table: person_id, person_name
second table: number_id, person_id, telephone no:
the relashion is 1 to many.
how can i add a record that the person_id to be in both tables automatically like in microsoft access?
do i have to use the DataRelation?
waiting
|
|
|
|
|
I was giving a higher lever overview because you insert/update it as two single tables rather than one joined table. I assumed you already knew how to do that.
Here is a simple example:
SqlCommand cmd = new SqlCommand();
cmd.Connection = myConnection;
cmd.CommandText = "INSERT table1(person_id, person_name) VALUES (@person_id, @person_name)";
cmd.Parameters.Add("@person_id", 1);
cmd.Parameters.Add("@person_name", "Joe Bloggs");
cmd.ExecuteNonQuery();
cmd = new SqlCommand();
cmd.Connection = myConnection;
cmd.CommandText = "INSERT table2(number_id, person_id, telephone_no) VALUES (@number_id, @person_id, @telephone_no)";
cmd.Parameters.Add("@number_id", 10);
cmd.Parameters.Add("@person_id", 1);
cmd.Parameters.Add("@telephone_no", "+44 131 332 4455");
cmd.ExecuteNonQuery();
Does this help?
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
yes this does help but i wanted to treat them as already in the relationship.
imagine a microsoft access form: in this case I would add only the person_name and telephone numbers without adding the person_id from the child table manualy.in this case it would be copied in the second table automatically due to the relationship.
I want to create an update form like in access.
do you have any ideea?
thanks very much for your fast help.
ex:
person_id 1 (autoseed-i don't have to insert)
person_name micu valentin
number_id 1(autoseed-i don't have to insert)
person_id (to update i have to copy this from the form-this is my problem-he must be copied from the parent table)number 123455
|
|
|
|
|
You say "link in Access" which suggests you are not using Access. You don't say what you are using so I'll assume SQL Server 2000 (which is the most common database in use on this forum)
You change the SqlCommand.CommandText on the first INSERT to something like this:
INSERT table1 (person_name) VALUES(@person_name); SELECT @@IDENTITY; And instead of using ExecuteNonQuery() use this:
int personID = cmd.ExecuteScalar() (You can obviously delete the line that adds the parameter for the person_id .
In the second command, you use the personID you got from the first query for the @person_id parameter.
Does this help?
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
Hi, my question is in regards to record locking and updating datasets in a multiuser environment. We have a database that is used to track items in inventory. This windows application is multiuser and accesses a Microsoft access database. We do not want to use databinding for future maintenance and have been using datasets to populate our user interface. The problem we have noticed is that when two users open the same customer at the same time, one user can delete or modify the data and the other user will not be able to see the updated changes on their application. Is there any way to solve this issue? Thank you
|
|
|
|
|
I had a similar issue in an asp.net page. Two users would load the same dataset and whoever saved last would update the database. If the data is not connected there is nothing you can do about it. What I did was implement a save feature that required the user to save the data every two minute. This minimized the problem.
"People who never make mistakes, never do anything."
My blog
http://toddsnotsoamazinglife.blogspot.com/
|
|
|
|
|
ToddHileHoffer wrote:
What I did was implement a save feature that required the user to save the data every two minute. This minimized the problem.
The solution is that when the user saves the information you check what the user was originally presented with with the current contents of the database, if there is no change then the save operation completes. If there is a change between what is currently in the database with what was in the database then the user is informed of the differences and is offered choices to overwrite, merge or cancel their save operation.
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
Hello!
First I have to say that I am a beginner - until some weeks I only had basic SQL knowledge.
Now I am working with the SQL server and I learned a lot about ADO.NET.
My question now is:
How can I hide the data from the customer?
The problem is that we are developing an application and it may be that that the customer would try to manipulate the data if he has the tools to do that.
But we want him only to use our application to work with the data!
So do I have to use the user administration or is there a better strategy how to solve this problem?
Thanks for any help
|
|
|
|
|
Simple: Don't grant them the rights to manipulate the data. Ensure they log on using a restricted account that only allows them access to the functionality that they need. Your application should use an specific account that grants the application only access to the parts of the database it needs.
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|