I want to insert Values to access table by using VBA control is there is any simple way to do this. i try this code but it does not work properly if i run this code it give the error 'variable not set' can anyone help me. thanks in advance
Private Sub CommandButton1_Click()
Dim cn As ADODB.Connection
Dim strSql As String
Dim lngKt As Long
Dim dbConnectStr As String
Dim Catalog As Object
Dim cnt As ADODB.Connection
Dim dbPath As String
Dim myRecordset As New ADODB.Recordset
Dim SQL As String, SQL2 As String
dbPath = "table.accdb"
dbConnectStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbPath & ";"
SQL = "INSERT INTO Jun_pre (ProductName,DESCRIPTION,SKU,MT,(mt),MRP,Remark,no_of_units_in_a_case) VALUES (""aa"",""bb"",""test"",""testUnit"",""1"",""2"",,""3"",,""4"");"
With cnt
.Open dbConnectStr 'some other string was there
.Execute (SQL)
.Close
End With
End Sub
Hi!
I'm having some trouble with my EF Code First model when saving a relation to a many to many relationship. My Models:
public class Event
{
public int Id { get; set; }
public string Name { get; set; }
public virtual ICollection<Tag> Tags { get; set; }
}
public class Tag
{
public int Id { get; set; }
public string Name { get; set; }
public virtual ICollection<Event> Events { get; set; }
}
In my controller, I map one or many TagViewModels into type of Tag, and send it down to my servicelayer for persistence. At this time by inspecting the entities the Tag has both Id and Name (The Id is a hidden field, and the name is a textbox in my view)
The problem occurs when I now try to add the Tag to the Event. Let's take the following scenario:
The Event is already in my database, and let's say it already has the related tags C#, ASP.NET
If I now send the following list of tags to the servicelayer:
ID Name
1 C#
2 ASP.NET
3 EF4
and add them by first fetching the Event from the DB, so that I have an actual Event from my DbContext, then I simply do
myEvent.Tags.Add
to add the tags.. Problem is that after SaveChanges() my DB now contains this set of tags:
ID Name
1 C#
2 ASP.NET
3 EF4
4 C#
5 ASP.NET
This, even though my Tags that I save has it's ID set when I save it (although I didn't fetch it from the DB)
Right now i'm doing some tests involving entityFramework and WCF. As I understand, the EntityObjects generated are DataContracts and so, they can be serialized to the client.
In my example I have a "Country" entity wich has 1 "Currency" as a property, when I get a Country and try to send it to the client, it throws an exception saying the data cant be written.
But, the thing is, if I Get a Currency (which has a collection of Countries) and dont load its countries, it does work. The client gets all the entities.
So, as a summary:
- I have an entity with another entity as a property and cant be serialized.
- I have another entity with an empty list of properties and it is successfully serialized.
Any ideas on how to make it work?
is there any way to increase performance of SQL server inserts, as you can see below i have used below sql 2005, 2008 and oracle. i am moving data from ORACLe to SQL.
while inserting data to SQL i am using a procedure.
insert to Oracles is very fast in compare to SQL, is there any way increase performance. or a better way to move data from Oracle to SQL (data size approx 100000 records an hour)
please find below stats as i gathered, RUN1 and RUN2 time is in millisecond.
hi,
I am creating a line in canvas tag using jquery drawing library. After the line drawn the
<div id="cool"><canvas id="canid"></canvas></div>
Then on click the below code executed.
$('#canid').remove();
What happens in IE after removing, dom with canvas end tag and also line is not removed.
Please help me out!.
I am new to Java Generics, and I'm currently experimenting with Generic Coding....final goal is to convert old Non-Generic legacy code to generic one...
I have defined two Classes with IS-A i.e. one is sub-class of other.
public class Parent {
private String name;
public Parent(String name) {
super();
this.name = name;
}
}
public class Child extends Parent{
private String address;
public Child(String name, String address) {
super(name);
this.address = address;
}
}
Now, I am trying to create a list with bounded Wildcard. and getting Compiler Error.
List<? extends Parent> myList = new ArrayList<Child>();
myList.add(new Parent("name")); // compiler-error
myList.add(new Child("name", "address")); // compiler-error
myList.add(new Child("name", "address")); // compiler-error
Bit confused. please help me on whats wrong with this ?
One of the touted advantages of jQuery.data versus raw expando properties (arbitrary attributes you can assign to DOM nodes) is that jQuery.data is "safe from circular references and therefore free from memory leaks". An article from Google titled "Optimizing JavaScript code" goes into more detail:
The most common memory leaks for web applications involve circular
references between the JavaScript script engine and the browsers' C++
objects' implementing the DOM (e.g. between the JavaScript script
engine and Internet Explorer's COM infrastructure, or between the
JavaScript engine and Firefox XPCOM infrastructure).
It lists two examples of circular reference patterns:
DOM element → event handler → closure scope → DOM
DOM element → via expando → intermediary object → DOM element
However, if a reference cycle between a DOM node and a JavaScript object produces a memory leak, doesn't this mean that any non-trivial event handler (e.g. onclick) will produce such a leak? I don't see how it's even possible for an event handler to avoid a reference cycle, because the way I see it:
The DOM element references the event handler.
The event handler references the DOM (either directly or indirectly). In any case, it's almost impossible to avoid referencing window in any interesting event handler, short of writing a setInterval loop that reads actions from a global queue.
Can someone provide a precise explanation of the JavaScript ↔ DOM circular reference problem? Things I'd like clarified:
What browsers are effected? A comment in the jQuery source specifically mentions IE6-7, but the Google article suggests Firefox is also affected.
Are expando properties and event handlers somehow different concerning memory leaks? Or are both of these code snippets susceptible to the same kind of memory leak?
// Create an expando that references to its own element.
var elem = document.getElementById('foo');
elem.myself = elem;
// Create an event handler that references its own element.
var elem = document.getElementById('foo');
elem.onclick = function() {
elem.style.display = 'none';
};
If a page leaks memory due to a circular reference, does the leak persist until the entire browser application is closed, or is the memory freed when the window/tab is closed?
I'm trying to implement a simple projectile motion in Android (with openGL).
And I want to add gravity to my world to simulate a ball's dropping realistically.
I simply update my renderer with a delta time which is calculated by:
float deltaTime = (System.nanoTime()-startTime) / 1000000000.0f;
startTime = System.nanoTime();
screen.update(deltaTime);
In my screen.update(deltaTime) method:
if (isballMoving) {
golfBall.updateLocationAndVelocity(deltaTime);
}
And in golfBall.updateLocationAndVelocity(deltaTime) method:
public final static double G = -9.81;
double vz0 = getVZ0(); // Gets initial velocity(z)
double z0 = getZ0(); // Gets initial height
double time = getS(); // gets total time from act begin
double vz = vz0 + G * deltaTime; // calculate new velocity(z)
double z = z0 - vz0 * deltaTime- 0.5 * G * deltaTime* deltaTime; // calculate new position
time = time + deltaTime; // Update time
setS(time); //set new total time
Now here is the problem;
If I set deltaTime as 0.07 statically, then the animation runs normally. But since the update() method runs as faster as it can, the length and therefore the speed of the ball varies from device to device.
If I don't touch deltaTime and run the program (deltaTime's are between 0.01 - 0.02 with my test devices) animation length and the speed of ball are same at different devices. But the animation is so SLOW!
What am I doing wrong?
I have an appender setup like this
<appender name="Scheduler_Appender" type="log4net.Appender.RollingFileAppender">
<file value="c:\temp\ApplicationLog.txt"/>
<rollingStyle value="Date"/>
<datePattern value="yyyyMMdd"/>
<appendToFile value="true"/>
<staticLogFileName value="true"/>
<layout type="MinLayout">
<locationInfo value="true"/>
</layout>
</appender>
When the log file first gets created the file name is simply ApplicationLog.txt this is correct.
However when the logging rolls - the filename that gets generated is ApplicationLog.txt20100323 (for example), and not ApplicationLog20100323.txt
How can I change the configuration so files are rolled to [FileName][Date].[ext] rather than [FileName].[ext][Date]
Thanks
I recently got MySQL compiled and working on Cygwin, and got a simple test example from online to verify that it worked. The test example compiled and ran successfully.
However, when incorporating MySQL in a hobby project of mine it isn't compiling which I believe is due to how the Makefile is setup, I have no experience with Makefiles and after reading tutorials about them, I have a better grasp but still can't get it working correctly.
When I try and compile my hobby project I recieve errors such as:
Obj/Database.o:Database.cpp:(.text+0x492): undefined reference to `_mysql_insert_id'
Obj/Database.o:Database.cpp:(.text+0x4c1): undefined reference to `_mysql_affected_rows'
collect2: ld returned 1 exit status
make[1]: *** [build] Error 1
make: *** [all] Error 2
Here is my Makefile, it worked with compiling and building the source before I attempted to put in MySQL support into the project. The LIBMYSQL paths are correct, verified by 'mysql_config'.
COMPILER = g++
WARNING1 = -Wall -Werror -Wformat-security -Winline -Wshadow -Wpointer-arith
WARNING2 = -Wcast-align -Wcast-qual -Wredundant-decls
LIBMYSQL = -I/usr/local/include/mysql -L/usr/local/lib/mysql -lmysqlclient
DEBUGGER = -g3
OPTIMISE = -O
C_FLAGS = $(OPTIMISE) $(DEBUGGER) $(WARNING1) $(WARNING2) -export-dynamic $(LIBMYSQL)
L_FLAGS = -lz -lm -lpthread -lcrypt $(LIBMYSQL)
OBJ_DIR = Obj/
SRC_DIR = Source/
MUD_EXE = project
MUD_DIR = TestP/
LOG_DIR = $(MUD_DIR)Files/Logs/
ECHOCMD = echo -e
L_GREEN = \e[1;32m
L_WHITE = \e[1;37m
L_BLUE = \e[1;34m
L_RED = \e[1;31m
L_NRM = \e[0;00m
DATE = `date +%d-%m-%Y`
FILES = $(wildcard $(SRC_DIR)*.cpp)
C_FILES = $(sort $(FILES))
O_FILES = $(patsubst $(SRC_DIR)%.cpp, $(OBJ_DIR)%.o, $(C_FILES))
all:
@$(ECHOCMD) " Compiling $(L_RED)$(MUD_EXE)$(L_NRM).";
@$(MAKE) -s build
build: $(O_FILES)
@rm -f $(MUD_EXE)
$(COMPILER) -o $(MUD_EXE) $(L_FLAGS) $(O_FILES)
@echo " Finished Compiling $(MUD_EXE).";
@chmod g+w $(MUD_EXE)
@chmod a+x $(MUD_EXE)
@chmod g+w $(O_FILES)
$(OBJ_DIR)%.o: $(SRC_DIR)%.cpp
@echo " Compiling $@";
$(COMPILER) -c $(C_FLAGS) $< -o $@
.cpp.o:
$(COMPILER) -c $(C_FLAGS) $<
clean:
@echo " Complete compile on $(MUD_EXE).";
@rm -f $(OBJ_DIR)*.o $(MUD_EXE)
@$(MAKE) -s build
I like the functionality of the Makefile, instead of spitting out all the arguments etc, it just spits out the "Compiling [Filename]" etc.
If I add -c to the L_FLAGS then it compiles (I think) but instead spits out stuff like:
g++: Obj/Database.o: linker input file unused because linking not done
After a full day of trying and research on google, I'm no closer to solving my problem, so I come to you guys to see if you can explain to me why all this is happening and if possible, steps to solve.
Regards,
Steve
I need to add a link over the entirety of a div which contains some more divs. Looks like this:
div.top
{
width: 150px;
height: 150px;
position: relative;
}
a.link
{
width: 150px;
height: 150px;
position: absolute;
top: 0;
}
<div class="top">
<div class="text1">Text 1</div>
<div class="text2">Text 2</div>
<a class="link" href="http://something"></a>
</div>
So I put a link inside and made it the size of the top div. Everythign works fine in Firefox, Safari and Chrome. In IE and Opera, whenever I hover mouse cursor over that area but also over a text, the cursor is changing to selection cursor, not a hand (meaning no link). Whenever I move the cursor off the text, the link is available again.
How can I make the link to "cover" the text completely? I tried adding z-index:
div.top
{
z-index: 0;
}
a.link
{
z-index: 1;
}
doesn't help.
Any ideas?
I'm trying to solve this problem where I have a unique array of values within a specific range. Take this scenario: Generate a fixed value array (90) with unique entries. If you find a duplicate, remove, reindex, and fill the void. I'm running into the problem that conditional statements do not allow you to interact with an array outside of it's scope. I'm aware of array_unique but it doesn't refill those gaps, just makes them. How do I refill those gaps?
Hey everyone,
So, for a very silly project in C++, we are making our own long integer class, called VLI (Very Long Int). The way it works (they backboned it, blame them for stupidity) is this:
User inputs up to 50 digits, which are input as string.
String is stored in pre-made Sequence class, which stores the string in an array, in reverse order.
That means, when "1234" is input, it gets stored as [4|3|2|1].
So, my question is this: How can I go about doing division using only these arrays of chars?
If the input answer is over 32 digits, I can't use ints to check for stuff, and they basically saying using long ints here is cheating.
Any input is welcome, and I can give more clarification if need be, thanks everyone.
I have a list of checkboxes like you would see in most email clients (You tick a box press delete then it deletes an email).
<input type="checkbox" value="yes" name="box[]" />
The problem stands here ...
print_r($_POST['box']);//Returns nothing at all ...
var_dump($_POST['box']);// returns null...
I was reading something about register globals that php5 has turned it off for security reason.
Does anyone know what my options are ?
I'm developing a prototype responsive wordpress theme version of my homepage. I'm running into issues with the fader on the homepage.
http://dev.epicwebdesign.ca/epicblog/
When the image switches, it uses position:absolute to overlay the pictures, then goes back to position:relative.
I need to make the absolute be relative to the bottom left corner of the menu instead of the top left corner of #wrap so it doesn't overlap.
I tried putting it in a container div like this: http://wiki.orbeon.com/forms/doc/contributor-guide/browser#TOC-Absolutely-positioned-box-inside-a-box-with-overflow:-auto-or-hidden but that doesn't seem to work.
Any ideas?
There are major CSS compatibility issues in IE, try it in chrome. It should look similar to http://epicwebdesign.ca. When the browser window is shrunk horizontially, the whole theme compensates.
Hi All,
I have a asp.net page which is checking a UNC path on a listbox item change event using Directory.exist method.
This works fine in Internet explorer.
But when i use firefox and debugging this method returns false even though the directory exists.
What could be the reason for this strange problem.
Please someone answer this
Thanks
SNA
I got an error when I was trying to draw gradient in Swift code:
GradientView.swift:31:40: Could not find an overload for '__conversion' that accepts the supplied arguments
Here is my code:
let context : CGContextRef = UIGraphicsGetCurrentContext()
let locations :CGFloat[] = [ 0.0, 0.25, 0.5, 0.75 ]
let colors = [UIColor.redColor().CGColor,UIColor.greenColor().CGColor,UIColor.blueColor().CGColor, UIColor.yellowColor().CGColor]
let colorspace : CGColorSpaceRef = CGColorSpaceCreateDeviceRGB()
let gradient : CGGradientRef = CGGradientCreateWithColors(colorspace, colors, locations)
//CGGradientCreateWithColors(colorspace,colors,locations)
let startPoint : CGPoint = CGPointMake(0, 0)
let endPoint : CGPoint = CGPointMake(500,500)
CGContextDrawLinearGradient(context, gradient,startPoint, endPoint, 0);
The problem is the CGGradientCreateWithColors takes CFArray not a normal Swift Array. I have no idea how to convert CFArray to Array and can't find anything in Apple's document. Any idea? Thanks
Why on earth won't this compile? Scala 2.8.0RC3:
Java
public interface X {
void logClick(long ts, int cId, String s, double c);
}
Scala
class Y extends X {
def logClick(ts: Long, cId: Int,sid: java.lang.String,c: Double) : Unit = {
...
}
}
Error
class Y needs to be abstract, since method logClick in trait X of type
(ts: Long,cId: Int,s: java.lang.String,c: Double)Unit is not defined
I'm trying to make a program so that I can run it through the command line with the following format:
./myProgram
I made it executable and put #!/usr/bin/env python in the header, but it's giving me the following error.
env: python\r: No such file or directory
However, when I run "python myProgram", it runs fine. Can someone tell me what I'm doing wrong?
OK So I have been messing with this all day long. I am fairly new to Python FTP. So I have searched through here and came up w/ this:
images = notions_ftp.nlst()
for image_name in image_names:
if found_url == False:
try:
for image in images:
ftp_image_name = "./%s" % image_name
if ftp_image_name == image:
found_url = True
image_name_we_want = image_name
except:
pass
# We failed to find an image for this product, it will have to be done manually
if found_url == False:
log.info("Image ain't there baby -- SKU: %s" % sku)
return False
# Hey we found something! Open the image....
notions_ftp.retrlines("RETR %s" % image_name_we_want, open(image_name_we_want, "rb"))
1/0
So I have narrowed the error down to the line before I divide by zero. Here is the error:
Traceback (most recent call last):
File "<console>", line 6, in <module>
File "<console>", line 39, in insert_image
IOError: [Errno 2] No such file or directory: '411483CC-IT,IM.jpg'
So if you follow the code you will see that the image IS in the directory because image_name_we_want is set if found in that directory listing on the first line of my code. And I KNOW it's there because I am looking at the FTP site myself and ...it's freakin there. So at some point during all of this I got the image to save locally, which is most desired, but I have long since forgot what I used to make it do that. Either way, why does it think that the image isn't there when it clearly finds it in the listing.
I have read about 10 different posts here about this problem, and I have tried every single one and the error will not go away. So here goes:
I am trying to have a nested form on my users/new page, where it accepts user-attributes and also company-attributes. When you submit the form:
Here's what my error message reads:
ActiveModel::MassAssignmentSecurity::Error in UsersController#create
Can't mass-assign protected attributes: companies
app/controllers/users_controller.rb:12:in `create'
Here's the code for my form:
<%= form_for @user do |f| %>
<%= render 'shared/error_messages', object: f.object %>
<%= f.fields_for :companies do |c| %>
<%= c.label :name, "Company Name"%>
<%= c.text_field :name %>
<% end %>
<%= f.label :name %>
<%= f.text_field :name %>
<%= f.label :email %>
<%= f.text_field :email %>
<%= f.label :password %>
<%= f.password_field :password %>
<%= f.label :password_confirmation %>
<%= f.password_field :password_confirmation %>
<br>
<% if current_page?(signup_path) %>
<%= f.submit "Sign Up", class: "btn btn-large btn-primary" %> Or, <%= link_to "Login", login_path %>
<% else %>
<%= f.submit "Update User", class: "btn btn-large btn-primary" %>
<% end %>
<% end %>
Users Controller:
class UsersController < ApplicationController
def index
@user = User.all
end
def new
@user = User.new
end
def create
@user = User.create(params[:user])
if @user.save
session[:user_id] = @user.id #once user account has been created, a session is not automatically created. This fixes that by setting their session id. This could be put into Controller action to clean up duplication.
flash[:success] = "Your account has been created!"
redirect_to tasks_path
else
render 'new'
end
end
def show
@user = User.find(params[:id])
@tasks = @user.tasks
end
def edit
@user = User.find(params[:id])
end
def update
@user = User.find(params[:id])
if @user.update_attributes(params[:user])
flash[:success] = @user.name.possessive + " profile has been updated"
redirect_to @user
else
render 'edit'
end
#if @task.update_attributes params[:task]
#redirect_to users_path
#flash[:success] = "User was successfully updated."
#end
end
def destroy
@user = User.find(params[:id])
unless current_user == @user
@user.destroy
flash[:success] = "The User has been deleted."
end
redirect_to users_path
flash[:error] = "Error. You can't delete yourself!"
end
end
Company Controller
class CompaniesController < ApplicationController
def index
@companies = Company.all
end
def new
@company = Company.new
end
def edit
@company = Company.find(params[:id])
end
def create
@company = Company.create(params[:company])
#if @company.save
#session[:user_id] = @user.id #once user account has been created, a session is not automatically created. This fixes that by setting their session id. This could be put into Controller action to clean up duplication.
#flash[:success] = "Your account has been created!"
#redirect_to tasks_path
#else
#render 'new'
#end
end
def show
@comnpany = Company.find(params[:id])
end
end
User model
class User < ActiveRecord::Base
has_secure_password
attr_accessible :name, :email, :password, :password_confirmation
has_many :tasks, dependent: :destroy
belongs_to :company
accepts_nested_attributes_for :company
validates :name, presence: true, length: { maximum: 50 }
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email, presence: true,
format: { with: VALID_EMAIL_REGEX },
uniqueness: { case_sensitive: false }
validates :password, length: { minimum: 6 }
#below not needed anymore, due to has_secure_password
#validates :password_confirmation, presence: true
end
Company Model
class Company < ActiveRecord::Base
attr_accessible :name
has_and_belongs_to_many :users
end
Thanks for your help!!
i am using fancybox.net for my light boxes. it works great with images. but when i use iframe option i am having problems with encoding.
i use hebrew and english and russian on my website. when i use UTF-8 on the iframe page i get squares instead of hebrew letters.
when i change to iso-8859-8 i have hebrew but inverted, and russian goes: ???????????
any idea? my website is UTF-8 and every thing works great.. except fancybox :(
The definition of runProcess() method in PipelineManager is
public PipelineResult runProcess(String pChainId, Object pParam)
throws RunProcessException
This gives me an impression that ANY object can be passed as the second param. However, ATG OOTB has PipelineManager component referring to CommercePipelineManager class which overrides the runProcess() method and downcast pParam to map and adds siteId to it.
Basically, this enforces the client code to send only Map. Thus, if one needs to create a new pipeline chain, has to use map as data structure to pass on the data. Offcourse, one can always get around this by creating a new PipelineManager component, but I was just wondering the thought behind explicitly using map in CommercePipelineManager