|
Hi
This is part of a sp to search on db.
set @sql = @sql + N' and (summary like ''%' + @keywords + '%'')'
but it doesnt find unicode cells of table.
what should i do ?
|
|
|
|
|
Dont't use concated SQL... for this.
Create a procedure and just add the value as paramter..
Also.. beaware of the collation...
/M
|
|
|
|
|
Hello friends,
I got some problem...
I have table like
CREATE TABLE publishers
(
Name char(4) NOT NULL,
ID varchar(40) NULL,
City varchar(20) NULL,
State char(2) NULL,
Comments varchar(3000) NOT NULL
)
I have some store procedure which put xml files and put that into this sql table, now problem i am facing here is that all the character from comments column i am not getting , I already increase the width of that column from varchar(1000 ) to varchar(3000)
Two days before i am getting well results i.e. all the character from this perticular field(comments) and seeing that result, character in that field was just 800 to 850 approx.But now why I am getting like that??? One thing is sure the character which is coming from XML file is not more than 850.Then is there any setting should i change or by mistake changed??
Please Help me out!
T.I.A
Shashank
|
|
|
|
|
Try nvarchar instead of varchar.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
check the prameters for the procedure.. they has to be the same as for the table...
/M
|
|
|
|
|
I have a problem to connect to a remote SQL Server in WinXp SP2.
The error is "SQL Server does not exist or access denied".
I've done almost all of the solutions that are recommended in Microsoft support service.
I added sqlservr.exe program into the exception list of firewall included with XP SP2.
I added 1433 (TCP) and 1434 (UDP) ports into that exception list as well.
Even I disable XP SP2 firewall. but I got the problem again.
Finally I installed SQL Server Service Pack 3a but unfortunately the problem is still exist.
I really don't know what should I do after doing all of the above tasks.
Is there anybody here who can solve this problem?
Thank you in advance.
|
|
|
|
|
---Check if there is a program uses the Same ports
---Check Your Domain Account when you Try to Connect to the Server
---Try to Connect by IP address not the DNS
---check the Secury Setting in the SQL server
---Check if the Server has a firewall that prevent you from Connect
---Norton Firewall ...?
agmb
|
|
|
|
|
How does the connection string looks like...? note that the SQL-server supports several instances and that that might be a peoblem if the instance nto is specified...
/M
|
|
|
|
|
Try:
select * <br />
from aaa cross join aaaa2 <br />
where aaa.q = 1<br />
and aaaa2.e = 7
Or:
select * <br />
from aaa, aaaa2 <br />
where aaa.q = 1<br />
and aaaa2.e = 7
|
|
|
|
|
its a wrongggggggggggggggg answer u have to check ur answers first, i found another soultion which is left join or full join with omition of the alter, however tanks for trying helping me........
Thanks alot
Hamody
|
|
|
|
|
Mohammad Daba`an wrote:
its a wrongggggggggggggggg answer
That was not very polite.
Mohammad Daba`an wrote:
i found another soultion which is left join or full join with omition of the alter
Huh?! Your original request was "i need to change the following code to another one which does the same function without using join, left outer joi, or any join statements"
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
Hmmm... strange select.
First of an outer join without a join... hmmm..
What the result is I can not predicct... What is the result you are looking for...?
/M
|
|
|
|
|
i have the following code:
while(true)
{
Thread.Sleep(delay);
SqlConnection connection = new SqlConnection;
connection.Open();
'some code here'
connection.Close();
}
i'm wondering how many sqlconnection will be made? after a while is it possible to get an "System.NullRefferenceException: Object not set to an instance of an object"(probably because the new connections are instantiated, but never disposed)?
thanks.
MetalSandman.
|
|
|
|
|
|
i have a project written in C# using and ODBC database that use SQL pervasive
SQL Driver ,
Problem:
when i run the windows application that lunch the report in my Computer every thing works fine
but when i run the application and try to run report from another computer that have the same ODBC access the Application Threw an Exception Message Said 'ReportDocumetn Threw Exception'
//---Notes
the Report is built by VS.NET Crystal Report IDE : its a Class
DataAdapter filling Data in the Other Machine : C# Code have No Error
Go East Go West C# is the Best
agmb
|
|
|
|
|
Can you force the SELECT command to select only a single row?
Im using the following:
SELECT * from SomeTable(UPDLOCK) where....
I don´t wanna lock all the tables that the SELECT returns, I wanna lock ONLY one. Is that possable?
|
|
|
|
|
|
hello
just write the query..
select top 1 from tablename where ..........
it will fetch only the first record that matches the condition...
hope will work for u.
bye
pankaj
|
|
|
|
|
execute @OLEResult = sp_OAMethod @FS, 'name',@FileName out
i'm not getting the filename using the above line in my SQL SP
Regards
Wilbur J. Pereira
"If they love me let them, for the heck of it.If they don't, who da heck cares about it"
|
|
|
|
|
Hello all,
I"m trying to write the core portion of a app that will sum the total amount (Amount)of money collected from start to end of a shift(Shift_Number), then return that value to (-currently-) the Console. I can get the the app to run, take the inputs of the machine name (Location_ID) and the last shift (Shift_Number), but it failes after it takes the last input,I get "Specified cast is not valid". I've enclosed the code, the database is sql, i'm sure you could change it to northwind and find a table with some numbers to sum and check against. written in C#, and using the console app template...
any help will be most apreciated!
<code>static void Main(string[] args)
{
try
{
SqlConnection LoadLastConnection = new SqlConnection();
LoadLastConnection.ConnectionString = "User ID=blah;Password=Blah;Initial Catalog=sellmdat2kSQL;Data Source=jpltpharos";
LoadLastConnection.Open();
Console.Write("Please enter a Machine_Number(4 characters): ");
string Machine_Number = Console.ReadLine();
Console.Write("Please enter the Last_Shift_Number(4 characters): ");
string Last_Shift_Number = Console.ReadLine();
SqlCommand LoadLastInvoiceCmd = new SqlCommand();
LoadLastInvoiceCmd.Connection = LoadLastConnection;
LoadLastInvoiceCmd.CommandText = "SELECT sum (Amount) From Transaction_table WHERE Location_ID = @machineName and Shift_Number = @ShiftNumber" ;
LoadLastInvoiceCmd.Parameters.Add("@machineName", Machine_Number);
LoadLastInvoiceCmd.Parameters.Add("@ShiftNumber", Last_Shift_Number);
SqlDataReader dataReader = LoadLastInvoiceCmd.ExecuteReader();
while (dataReader.Read())
{
int last_invoice = dataReader.GetInt32(0);
string Amount = dataReader.GetString(1);
Console.WriteLine("Current Invoice Period is {0}\nAnd the Cash Value is {1}\nTotal Dollars", last_invoice, Amount);
}
dataReader.Close();
LoadLastConnection.Close();
}
catch(Exception e)
{
Console.WriteLine("An error occurred accessing the database:" + e.Message);
}
}</code>
Dim Beautiful As String
Beautiful = "ignorant"
Label1.Text = "The world is full of " & Beautiful & " people."
Why is common sense such an un-common comodity?
|
|
|
|
|
I'd say one of these is the problem:
int last_invoice = dataReader.GetInt32(0); string Amount = dataReader.GetString(1);
It would help more than a little if you first took the time to see what line is blowing up, and checked the data in the dataReader to see what it's trying to convert. Best guess, one of these is coming back with a NULL.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
ok,
so I've changed it a small bit, checked it, done the stack trace, and it is still failing,
but the catch -- e.Message is giving the following: incorrect syntax near 'transaction_ table'
and the catch -- e.StackTrace is giving the following:
at system.data.sqlclient.sqlcommand.executereader(commandbehavior cmdbehavior, runbehavior runbehavior, boolean returnstream)
at system.data.sqlclient.sqlcommand.executereader()
at reportorders.report.main(string[] args) in c:\documents and settings.....(it list the filename)report.cs:line28
Press any key to continue
line 34 is not the FROM Transaction_Table statement line...but rather the dataReader execution statement.
I've double checked query in query analizer and it works
what am I missing here? can I not do an aggregate function with the dataReader?
I will enclose the code again, in its modified version... (again, i'm using the C# console app template in vs.net 2003)
Also, you can comment / uncomment out the "Sequence_Number " from the query and from the
int Sequence_Number = dataReader.GetInt32(0); parts, as that is the primary key
Thanks, again...
using System;
using System.Data.SqlClient;
namespace ReportOrders
{
class Report
{
[STAThread]
static void Main(string[] args)
{
try
{
SqlConnection dataConnection = new SqlConnection();
dataConnection.ConnectionString = "user ID=blah;pwd=BLAH;Initial Catalog=sellmdat2kSQL;Data Source=localhost";
dataConnection.Open();
Console.WriteLine("Please enter a Location ID (4 characters): ");
string Location_ID = Console.ReadLine();
Console.WriteLine("Please enter a Shift Number (4 characters): ");
string Shift_Number = Console.ReadLine();
SqlCommand dataCommand = new SqlCommand();
dataCommand.Connection = dataConnection;
dataCommand.CommandText = "SELECT sum (Amount)as Amount";
dataCommand.CommandText += "FROM transaction_table WHERE Location_id ='" + Location_ID + "' and Shift_Number='" + Shift_Number + "'";
Console.WriteLine("About to execute: " + dataCommand.CommandText);
SqlDataReader dataReader = dataCommand.ExecuteReader();
while (dataReader.Read())
{
int Sequence_Number = dataReader.GetInt32(0);
if (dataReader.IsDBNull(2))
{
Console.WriteLine("Shift Number {0} not yet closed\n\n", Shift_Number);
}
else
{
string Amount = dataReader.GetString(0);
Console.WriteLine("Value {0}\nAdded Since Last Shift ", Amount );
}
}
dataReader.Close();
dataConnection.Close();
}
catch(Exception e)
{
Console.WriteLine("An error occurred accessing the database: " + e.StackTrace);
}
}
}
}
Dim Beautiful As String
Beautiful = "ignorant"
Label1.Text = "The world is full of " & Beautiful & " people."
Why is common sense such an un-common comodity?
|
|
|
|
|
wetrivrrat wrote:
dataCommand.CommandText = "SELECT sum (Amount)as Amount"; //dataCommand.CommandText = "SELECT Sequence_Number, sum (Amount)as Amount"; dataCommand.CommandText += "FROM transaction_table WHERE Location_id ='" + Location_ID + "' and Shift_Number='" + Shift_Number + "'"; Console.WriteLine("About to execute: " + dataCommand.CommandText);
If you look closely, your strings don't end with, or begin with a space. So you're trying to execute this:
SELECT sum (Amount)as AmountFROM transaction_table WHERE Location_id ='etc
when you want this:
SELECT sum (Amount)as Amount FROM transaction_table WHERE Location_id ='etc
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
ok, so that was the easy part,
now, i'm back to the earlier error of Specified cast is not found, and as you suppected the string Amount = dataReader.GetString(0); is the bad guy, but I know the value returned is not null, as i've ran the query before to test it, is my problem due to the fact that i'm creating a new field and it can't ref the new field? I know it is pulling the data down though because if i run it with the primary key i get a return that the return data is outside the boudaries of the array, which was expected due to the way sql returns the data... so ........
Dim Beautiful As String
Beautiful = "ignorant"
Label1.Text = "The world is full of " & Beautiful & " people."
Why is common sense such an un-common comodity?
|
|
|
|
|
I've even changed my query to select sum (amount) as Amount from transaction_table where sequence_table IN (select sequence_table from transaction_table where .....); and i still get the same error, so it seems like the problem is in the creation of that new field, any thoughts?
Dim Beautiful As String
Beautiful = "ignorant"
Label1.Text = "The world is full of " & Beautiful & " people."
Why is common sense such an un-common comodity?
|
|
|
|