|
Hi,everyone. i'm a newbie of VC,i'm sorry if the question bother you...
Here it is:
when i first added the Microsoft DataGrid Control, Version 6.0(OLEDB), and added a member variable to a class by Class Wizard. However, for some reason I didn't do it rightly, so I wanted to delete it. (I think i must delete it in a wrong way and left something!) I navigated to the variable in the header file, and I deleted it.
However, when I tried to reinsert the variable (once again by using Class Wizard, and choosing Add Member Variable), the former context menu didn't come out:
"The ActiveX Control "Microsoft DataGrid Control, Version 6.0(OLEDB)" has not been inserted into the project. Developer Studio will do this now and generate a C++ wrapper class for it." -- Dialog is expected.
instead, "Add Member Varible" dialog appears and the varible type datagrid1 exsits and i can't use it properly. i have searched in files i can't find string "datagrid" anymore,why does the compiler remember that
so i think i should reinsert the component,another question comes up:
why do they have "Project->Add to project->Components and Controls"
but don't have "Project->Minus to project->Components and Controls"
i don't know how to do,and hope someone can help me,and hope i describe the problem clearly...
Best wishes for all of you! and this is really a great place! i'm so enjoying being here and learn a lot! ^.^
Thank you! and Happy Thanksgiving!
You will when you believe!
|
|
|
|
|
i'm trying to restore a db from a windows app., but i had an error stating that the DB is in use and can't be restored.
can anyone help please ...
*********
CODE
********
public static void RestoreDB(string path)
{
string commandString="USE MASTER RESTORE DATABASE Guirguis FROM DISK = '"+path+"'"; //Guirguis : DB to restore
SqlConnection newConn=new SqlConnection();
newConn.ConnectionString="workstation id="+System.Environment.MachineName+";packet size=4096;integrated security=SSPI;data s" +"ource=\".\";persist security info=False;initial catalog=master";
command=new SqlCommand(commandString,newConn);
dbConnection.Close(); //connection may be using Guirguis
newConn.Open();
try
{
command.ExecuteNonQuery();
}
catch(Exception e)
{
newConn.Close();
throw new Exception(e.Message);
}
newConn.Close();
newConn.Dispose();
}
*******************
thanx
|
|
|
|
|
to restore a database you have to amke sure that there is no user currently logged into the database. Atleast in SQL Server you do.
So go into enterprise manage and check if ther are any users logged into before attempting a restore.
Kick the users out and then attempt the restore.
If it works then your code is fine , you jsut have to make sure that no user is using the db before attempting the restore
|
|
|
|
|
Hi,
I'm using the ADO.NET with C#. When I perform an SQL query on a table in which the primary key consists of multiple fields and the SQL query is done on fewer fields than the primary key I get an exception.
("No value given for one or more required parameters")
I get why this may not be allowed, but I could to this in the old ADO.
(let's say I want all the x's of y, then y & x consist of the primary key, but I still need to create a query that returns all the x's of a certain y)
Does anybody know if they changed that? or do I need to do something else.
Thanks!
|
|
|
|
|
Since you don't post your query or the C# code you are using to access it diagnosing the problem may be a little challenging.
sharonz wrote:
("No value given for one or more required parameters")
This indicates that there is a problem with the parameters you pass to the query rather than the query itself.
e.g.
SqlCommand cmd = new SqlCommand("MyStoredProc", connection);
cmd.Parameters.Add("@MyFirstParameter", someValue);
cmd.ExecuteNonQuery(); with the corresponding SQL
CREATE PROCEDURE dbo.MyStoredProc
@MyFirstParameter int,
@MySecondParameter int
AS
...
GO This would most likely give the same error message because you have missed one of the parameters.
If this does not give you the idea for the answer, please post the relevant code snippets.
Do you want to know more?
WDevs.com - The worlds first Developers Services Provider
|
|
|
|
|
Hi gurus,
I have created a blank Access database (mdb) and I would like to know how I can add a table, fields (columns) and records (rows) in C#.
Can anyone show me a sample code to do these operations please?
Best regards
There is no spoon.
|
|
|
|
|
I don't know Access specific syntax... But I can give some generic advice.
The OleDbCommand can accept just about any SQL string that you could give directly to the database. Therefore you just create your SQL and pass it to the command object then do command.ExecuteNonQuery() [as you don't require any results back] and it should work.
Do you want to know more?
WDevs.com - The worlds first Developers Services Provider
|
|
|
|
|
Anybody knows any good free data transformation tool and OLAP client tool? Thanks a lot.
<italic>Work hard and a bit of luck is the key to success. You don`t need to be genius, to be rich.
|
|
|
|
|
Grid only views Date part of a datetime objects(Fields) ...is there any mean to view the time part only or even both date and time.
thanx
Mr.Cooper
|
|
|
|
|
This probably belongs in the ASP.NET forum, but I'll take a stab at it anyway. I think you need to set the DataFormatString property of the appropriate BoundColumn object. Try, for example, setting it to {0:t} or {0:g} .
For more date/time formatting options, see Standard DateTime Format Strings[^] and Custom DateTime Format Strings[^] in the .NET Framework documentation.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Using the following code the first insert is ignored so only the 'y' and 'z' rows appear in the table. The table is empty before any of the inserts. Anybody know why this is happening? Is there an easier way of getting data into a table?
OleDbConnection cn = new OleDbConnection();<br />
cn.ConnectionString = @"Provider=Microsoft.JET.OLEDB.4.0;" +<br />
@"Data Source=" + sDBPath + ";" +<br />
@"Jet OLEDB:Engine Type=5";<br />
<br />
cn.Open();<br />
OleDbDataAdapter adap = new OleDbDataAdapter("SELECT * FROM Info",cn);<br />
OleDbCommand cmdInsert = new OleDbCommand();<br />
cmdInsert.Connection = cn;<br />
<br />
cmdInsert.CommandText = @"INSERT INTO Info (InfoDesc, InfoVal) VALUES (?, ?)";<br />
cmdInsert.Parameters.Add(new OleDbParameter("InfoDesc",OleDbType.VarWChar,50,"InfoDesc"));<br />
cmdInsert.Parameters.Add(new OleDbParameter("InfoVal",OleDbType.VarWChar,50,"InfoVal"));<br />
adap.InsertCommand = cmdInsert;<br />
<br />
DataSet ds = new DataSet();<br />
adap.Fill(ds,"Info");<br />
<br />
DataRow dr = null;<br />
dr = ds.Tables[0].NewRow();<br />
dr["InfoDesc"] = "x";<br />
dr["InfoVal"] = "x";<br />
ds.Tables[0].Rows.Add(dr);<br />
<br />
dr = ds.Tables[0].NewRow();<br />
dr["InfoDesc"] = "y";<br />
dr["InfoVal"] = "y";<br />
ds.Tables[0].Rows.Add(dr);<br />
<br />
dr = ds.Tables[0].NewRow();<br />
dr["InfoDesc"] = "z";<br />
dr["InfoVal"] = "z";<br />
ds.Tables[0].Rows.Add(dr);<br />
<br />
adap.Update(ds,"Info");<br />
ds.Dispose();<br />
cn.Close();>
Rugby League: The Greatest Game Of All.
|
|
|
|
|
I have a query which inserts data from one database to another. The two tables are identical. The problem is that when viewed through enterprise manager, you can see all the records(200 of them). However, when doing a select * in query analyser, it shows the results as 0. Has anyone ever come across this? If so, please let me know whats happening here. If you restart sql, you can then see the records in query analyser.
|
|
|
|
|
Sometimes in SQL 2000 you can end up with two tables that are named the same, but have different owners. So when you view in Enterprise Manager, you may be viewing the table owned by dbo, but when logged into query analyzer, you may be viewing the table owned by joeblow.
my blog
|
|
|
|
|
Hello,
I'm trying to write a stored procedure that retrieves the info for a quote, and number of products in that quote using COUNT . But if there's a quote that doesn't have any products yet (you create a quote with customer information and then you start adding products), no record is returned.
This is my code:
ALTER PROCEDURE dbo.Orders_ListaCotizaciones
(@NombreUsuario varchar(20))
AS SELECT dbo.Cotizaciones.ID_pedido, dbo.Cotizaciones.Nombre,
dbo.Cotizaciones.Ciudad + ', ' + dbo.Cotizaciones.Estado AS CiudadEstado,
COUNT(dbo.Cotizacion_Shutters.ID_shutter) AS NumShutters
FROM dbo.Cotizacion_Shutters LEFT OUTER JOIN
dbo.Cotizaciones ON dbo.Cotizacion_Shutters.ID_pedido = dbo.Cotizaciones.ID_pedido
INNER JOIN dbo.Empresas ON dbo.Cotizaciones.ID_empresa = dbo.Empresas.ID_empresa
INNER JOIN dbo.Usuarios ON dbo.Empresas.ID_empresa = dbo.Usuarios.ID_empresa
WHERE (dbo.Usuarios.NombreUsuario = @NombreUsuario)
GROUP BY dbo.Cotizaciones.ID_pedido, dbo.Cotizaciones.Nombre,
dbo.Cotizaciones.Ciudad + ', ' + dbo.Cotizaciones.Estado The Cotizaciones table may have a record with no associated records int Cotizacion_Shutters , and I want the stored procedure to return 0 for that quote. (The rest of the JOINs are to get the distributor ID from the logged on user name)
Just in case you wanted to know, I'm designing my stored procedure in Access (but it allows me to modify the SQL.)
Any ideas?
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
You have your OUTER JOIN the wrong way round. A LEFT outer join gives you all the rows in the left hand table joined with any matching rows in the right-hand table. If there are no rows on the right, the row will contain NULL for all columns in the right-hand table.
Either swap dbo.Cotizaciones and dbo.Cotizacion_Shutters around, or use a RIGHT OUTER JOIN . I don't think there's any performance difference between LEFT and RIGHT joins, the query optimiser typically does an equally good job whichever way you express your query.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Thank you very much for your help!! It works now!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
How to represent duration (in hours:minutes:sec) in SQL knowing that there is no data type to hold time objects ... only datetime
thanx in advance
Mr.Cooper
|
|
|
|
|
Use a datetime and ignore the date. If not, you could store a time in seconds and convert it, or whatever else you like.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
hi all i'm using VB.Net and i have a form that i need to have the results displayed into labels that populate the form.
this is what i have so far
**************** CODE *****************
Private Sub SearchTBBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SearchTBBtn.Click
Dim Cnxn As New ADODB.Connection
Dim cmdChange As ADODB.Command
'Connection String
Dim strCnxn As String
'SQL Query
Dim strSQL As String
'search criteria
Dim strSearchLName, strSearchFName As String
Dim Now As DateTime
Dim UserPassID As Integer
UserPassID = Val(lblPassID.Text)
'Now = DateTime()
' Now = Format(Now, "h:nnAM/PM")
strSearchLName = txtLName.Text
strSearchFName = txtFName.Text
' define strSQLUpdate to insert the fields
strSQL = "SELECT * FROM Contacts WHERE (LName) = '" & strSearchLName & "' AND (FName) = '" & strSearchFName & "'"
strCnxn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\RMSC LOGIN\MYDataBase.mdb;Persist Security Info=False"
Cnxn = New ADODB.Connection
Cnxn.Open(strCnxn)
cmdChange = New ADODB.Command ' Create command object
cmdChange.ActiveConnection = Cnxn
cmdChange.CommandText = strSQL
cmdChange.Execute() ' execute the SQL command
' Fill the fields with the results
'************* This is where i have a problem
Dim rsContact As New ADODB.Recordset
rsContact = cmdChange
lblPassID.Refresh()
lblLName.Refresh()
Cnxn.Close() ' Close everything
Cnxn = Nothing
End Sub
*************** END CODE ******************
i guess i don't knowhow to populate the labels with the results of cmdChange
any help would be great
thank you
Help is great only if yu ask correctly
|
|
|
|
|
I would like to move over to the mySQL database for my VS 2002 (V7.0) MFC application. (I have downloaded the current mySQL database and that works fine on my Windows 2000 PC).
I have then downloaded the file mysql++1.7.21.tar (C/C++ API) from the mySQL.com website to interface with my application, but it requires VS 2003 (7.1) to build this library.
Are they any binaries that I can download or how can I proceed.
I have been posting and searching and instructions etc on this interface but not making any progress.
|
|
|
|
|
|
I have bought sql server space, the hosting company as provided me with the login details.
Currently, I am connecting to my database using:
"server=TheIPAddress;uid=admin;pwd=pass;database=TheDatabase"
However, I realise that I should not connect to the database using 'admin' login details as this user is the administrator of the database and it would not be appropriate to this login.
So I tried to create additional users for my DB, but was unsuccessful. After contacting my hosting company, they told me that I cannot create additional users.
So I would like to ask what are my options????
Should I just use 'admin' login details, and hope that nothing serious happens. Or shoudl I really press the hosting company to create additioanl less-powerful users for me. Any other options??
thanks
|
|
|
|
|
If you had real admin rights, you'd be able to create the users...
The normal admin account for SQL Server isn't named 'admin', so they have probably created a non-admin account which has most rights in your database, but not in the others running on the server.
Steve S
Developer for hire
|
|
|
|
|
Yes, you are right. The account provided to us is 'db_owner' so it has full access to the database.
How dangerous is it to provide this account detail in the connection string. Are there any alternatives???
regards
|
|
|
|
|
Only alternative is to programmatically set the properties from code. If you were writing a server component to connect to a database in C++, this is relatively simple, but of course, if the password is compromised, the code needs to be recompiled...
The string should be on server side in ASP or similar, and never in an HTML page sent to the client, of course
Steve S
Developer for hire
|
|
|
|