|
Hi,
I am creating a simple SPROC in .NET (SQL Server 2005) and I want to send the content of a DataTable to the pipe. I'm not sure how to do this (all this is still quite new to all of us!).
Pipe.Send takes a SqlDataReader or SqlDataRecord as an argument. However, the DataTable can only return a DataTableReader with CreateDataReader.
Is there a way to cast something into something else to make this work? Casting the DataTableReader to a SqlDataReader doesn't work.
Thanks!
|
|
|
|
|
i want to generate a trigger on a table whenever the date of the system changes. Can any one help me.
Programmers Solutions is QAU Programmers
http://www.qauprogrammers.com
http://www.linksexchangedirectory.org
http://www.appleiphonetricks.com
http://www.dubaieclassifieds.com
http://www.eshopsdubai.com
http://www.faheemhabib.com
modified on Thursday, February 3, 2011 7:41 AM
|
|
|
|
|
You need to create a sql server agent job an run it daily. You can't run a trigger on on insert update and delete.
"People who never make mistakes, never do anything."
My blog
http://toddsnotsoamazinglife.blogspot.com/
|
|
|
|
|
i have problem to make connection to Server of Analysis Service in other computer. It's easy if i use local server, but i need to connect other server.
Can somebody help me?
NB: error message that show is "the server is either not started or too busy"
|
|
|
|
|
Hello
I have empt table where job_id is field in it.
I want to update empt table if job_id = '1' or '3' by '999'
And if job_id not '1' or '3' then update by '456'
So what's wrong with my cursor
T.I.A
Shashank
-----------------------------------------------------
CREATE procedure lnt.textt
@qurstr varchar(10)
AS
Declare @in AS Varchar(10)
Declare crs_cc cursor for select job_id from empt FOR UPDATE OF job_id
open crs_cc
fetch next from crs_cc INTO @in
while @@fetch_status = 0
IF @qurstr = '1' OR @qurstr = '3'
BEGIN
UPDATE empt set job_id = '999'
where job_id = @qurstr
print 'U Miss By Miles!!!!'
print @qurstr
END
IF @qurstr IN (SELECT job_id from empt where job_id not in ('1','3'))
BEGIN
update empt set job_id = '456'
where job_id = @qurstr
print ' Success'
END
FETCH NEXT FROM crs_cc
CLOSE crs_cc
DEALLOCATE crs_cc
GO
|
|
|
|
|
|
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
|
|
|
|